From 40b14981fdf592cb6845af03b193114353b7e7eb Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 11 Apr 2016 16:34:29 +0930 Subject: [PATCH] daemon: fix BIP68 support. We got the -> second translation wrong by a factor of 512, and also we need to move the median time in our tests otherwise bitcoind won't let us spend the tx. Signed-off-by: Rusty Russell --- bitcoin/locktime.c | 2 +- daemon/test/test.sh | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/bitcoin/locktime.c b/bitcoin/locktime.c index 05330f64f..a91c31537 100644 --- a/bitcoin/locktime.c +++ b/bitcoin/locktime.c @@ -66,7 +66,7 @@ u32 rel_locktime_to_seconds(const struct rel_locktime *rel) { assert(rel_locktime_is_seconds(rel)); #if HAS_BIP68 - return rel->locktime & BIP68_LOCKTIME_MASK; + return (rel->locktime & BIP68_LOCKTIME_MASK) << BIP68_SECONDS_SHIFT; #else return rel->locktime - SECONDS_POINT; #endif diff --git a/daemon/test/test.sh b/daemon/test/test.sh index 0dd077772..24094d58d 100755 --- a/daemon/test/test.sh +++ b/daemon/test/test.sh @@ -224,8 +224,11 @@ if [ -n "$TIMEOUT_ANCHOR" ]; then TIME=$(($TIME + 24 * 60 * 60)) lcli1 dev-mocktime $TIME + # Move bitcoind median time as well, so CSV moves. + $CLI setmocktime $TIME + $CLI generate 6 + # Due to laziness, we trigger by block generation. - $CLI generate 1 TIME=$(($TIME + 1)) lcli1 dev-mocktime $TIME sleep 2