From 8157e378f45c07925c9a67d4208207a0d421e4a7 Mon Sep 17 00:00:00 2001 From: Antoine Poinsot Date: Mon, 9 Aug 2021 08:52:23 +0200 Subject: [PATCH] wallet: correct CSV check in `deep_enough` Return false if the timelock didn't mature yet, not the other way around. Also, the check shouldn't be strict: if the CSV is 1 it is valid at utxo->blockheight + 1. Signed-off-by: Antoine Poinsot --- wallet/db_postgres_sqlgen.c | 2 +- wallet/db_sqlite3_sqlgen.c | 2 +- wallet/statements_gettextgen.po | 2 +- wallet/wallet.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/wallet/db_postgres_sqlgen.c b/wallet/db_postgres_sqlgen.c index 34e0b303c..539287837 100644 --- a/wallet/db_postgres_sqlgen.c +++ b/wallet/db_postgres_sqlgen.c @@ -2026,4 +2026,4 @@ struct db_query db_postgres_queries[] = { #endif /* LIGHTNINGD_WALLET_GEN_DB_POSTGRES */ -// SHA256STAMP:6353b67b3e4f539da2d1f0c2564c4a8243f07d59cd0b73bc83d5552600bd67f7 +// SHA256STAMP:27a166e040e517422e91cf7ffbd12426b34337b8d75f82d7aa4c448beae5e821 diff --git a/wallet/db_sqlite3_sqlgen.c b/wallet/db_sqlite3_sqlgen.c index 0b7fd17eb..c57cb3772 100644 --- a/wallet/db_sqlite3_sqlgen.c +++ b/wallet/db_sqlite3_sqlgen.c @@ -2026,4 +2026,4 @@ struct db_query db_sqlite3_queries[] = { #endif /* LIGHTNINGD_WALLET_GEN_DB_SQLITE3 */ -// SHA256STAMP:6353b67b3e4f539da2d1f0c2564c4a8243f07d59cd0b73bc83d5552600bd67f7 +// SHA256STAMP:27a166e040e517422e91cf7ffbd12426b34337b8d75f82d7aa4c448beae5e821 diff --git a/wallet/statements_gettextgen.po b/wallet/statements_gettextgen.po index 636c0bbc3..317b0406d 100644 --- a/wallet/statements_gettextgen.po +++ b/wallet/statements_gettextgen.po @@ -1337,4 +1337,4 @@ msgstr "" #: wallet/test/run-wallet.c:1696 msgid "INSERT INTO channels (id) VALUES (1);" msgstr "" -# SHA256STAMP:e203d19d9f4192ad6b3aa1a6f257d4f7b267df56c5de9810b573f0affa0122fd +# SHA256STAMP:3652b5850f08383c0f0c01a7f11c1a22ec2b4ac16018152d2770a73674fb05ec diff --git a/wallet/wallet.c b/wallet/wallet.c index 67cdc4c3c..02ba582d0 100644 --- a/wallet/wallet.c +++ b/wallet/wallet.c @@ -530,7 +530,7 @@ static bool deep_enough(u32 maxheight, const struct utxo *utxo, if (utxo->close_info) { u32 csv_free = *utxo->blockheight + utxo->close_info->csv; assert(csv_free > *utxo->blockheight); - if (csv_free < current_blockheight) + if (current_blockheight < csv_free) return false; } return *utxo->blockheight <= maxheight;