mirror of
https://github.com/aljazceru/lightning.git
synced 2026-02-07 07:04:25 +01:00
script: use the normalized delay script form for commit output.
As documented in the paper; it's also two bytes shorter, and allows us to use the exact same script for three cases. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -88,8 +88,8 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
/* Create redeem script */
|
||||
redeemscript = bitcoin_redeem_revocable(ctx, &pubkey1,
|
||||
locktime, &pubkey2, &rhash);
|
||||
redeemscript = bitcoin_redeem_secret_or_delay(ctx, &pubkey1, locktime,
|
||||
&pubkey2, &rhash);
|
||||
|
||||
/* Now, create transaction to spend it. */
|
||||
tx = bitcoin_tx(ctx, 1, 1);
|
||||
@@ -116,9 +116,9 @@ int main(int argc, char *argv[])
|
||||
&privkey, &pubkey1, &sig.sig))
|
||||
errx(1, "Could not sign tx");
|
||||
sig.stype = SIGHASH_ALL;
|
||||
tx->input[0].script = scriptsig_p2sh_single_sig(tx, redeemscript,
|
||||
tal_count(redeemscript),
|
||||
&sig);
|
||||
tx->input[0].script = scriptsig_p2sh_secret(tx, NULL, 0, &sig,
|
||||
redeemscript,
|
||||
tal_count(redeemscript));
|
||||
tx->input[0].script_length = tal_count(tx->input[0].script);
|
||||
|
||||
/* Print it out in hex. */
|
||||
|
||||
@@ -84,9 +84,9 @@ int main(int argc, char *argv[])
|
||||
|
||||
/* Now, which commit output? Match redeem script. */
|
||||
sha256(&revoke_hash, &revoke_preimage, sizeof(revoke_preimage));
|
||||
redeemscript = bitcoin_redeem_revocable(ctx, &pubkey2,
|
||||
locktime_seconds,
|
||||
&pubkey1, &revoke_hash);
|
||||
redeemscript = bitcoin_redeem_secret_or_delay(ctx, &pubkey2,
|
||||
locktime_seconds,
|
||||
&pubkey1, &revoke_hash);
|
||||
p2sh = scriptpubkey_p2sh(ctx, redeemscript);
|
||||
|
||||
for (i = 0; i < commit->output_count; i++) {
|
||||
|
||||
Reference in New Issue
Block a user