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:
Rusty Russell
2015-07-24 16:00:10 +09:30
parent d053181b0b
commit aa79887d79
5 changed files with 12 additions and 62 deletions

View File

@@ -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. */