protocol fix: use locktime from *other* side.

Which emerged clearly when setting one side's locktime differently than
the other.

Each side specifies the (minimum) time they need to notice a fraud attempt:
this constrains the *other* side.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2015-07-02 06:44:59 +09:30
parent 66b1df4036
commit 20bb6c65aa
4 changed files with 8 additions and 8 deletions

View File

@@ -34,7 +34,7 @@ int main(int argc, char *argv[])
struct sha256 rhash;
size_t i, p2sh_out;
u64 fee = 10000;
u32 locktime_seconds;
u32 locktime;
err_set_progname(argv[0]);
@@ -57,8 +57,8 @@ int main(int argc, char *argv[])
o1 = pkt_from_file(argv[2], PKT__PKT_OPEN)->open;
o2 = pkt_from_file(argv[3], PKT__PKT_OPEN)->open;
if (!proto_to_locktime(o1, &locktime_seconds))
errx(1, "Invalid locktime in o1");
if (!proto_to_locktime(o2, &locktime))
errx(1, "Invalid locktime in o2");
/* We need our private key to spend commit output. */
if (!key_from_base58(argv[4], strlen(argv[4]), &testnet, &privkey, &pubkey1))
@@ -89,8 +89,7 @@ int main(int argc, char *argv[])
/* Create redeem script */
redeemscript = bitcoin_redeem_revocable(ctx, &pubkey1,
locktime_seconds,
&pubkey2, &rhash);
locktime, &pubkey2, &rhash);
/* Now, create transaction to spend it. */
tx = bitcoin_tx(ctx, 1, 1);