locktime: nice abstractions for absolute and relative locktimes.

I got confused navigating these, especially since Alpha and Bitcoin
have diverged (BIP68 was proposed after Elements Alpha).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2016-01-22 06:38:08 +10:30
parent 4c42930940
commit 4b02c6f558
13 changed files with 185 additions and 89 deletions

View File

@@ -21,6 +21,7 @@
#include "test-cli/gather_updates.h"
#include "funding.h"
#include "version.h"
#include "bitcoin/locktime.h"
#include <unistd.h>
int main(int argc, char *argv[])
@@ -37,7 +38,7 @@ int main(int argc, char *argv[])
struct sha256 rhash;
size_t p2sh_out;
u64 fee = 10000;
u32 locktime;
struct rel_locktime locktime;
err_set_progname(argv[0]);
@@ -87,7 +88,7 @@ int main(int argc, char *argv[])
NULL, &rhash, NULL, NULL);
/* Create redeem script */
redeemscript = bitcoin_redeem_secret_or_delay(ctx, &pubkey1, locktime,
redeemscript = bitcoin_redeem_secret_or_delay(ctx, &pubkey1, &locktime,
&pubkey2, &rhash);
/* Now, create transaction to spend it. */
@@ -98,7 +99,7 @@ int main(int argc, char *argv[])
tx->input[0].input_amount = commit->output[p2sh_out].amount;
tx->fee = fee;
tx->input[0].sequence_number = bitcoin_nsequence(locktime);
tx->input[0].sequence_number = bitcoin_nsequence(&locktime);
if (commit->output[p2sh_out].amount <= fee)
errx(1, "Amount of %llu won't exceed fee",