mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-20 07:34:24 +01:00
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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user