From 453bfbc816c27f7c0dd05cfcb7a8e969bbb7f5f3 Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Tue, 17 Mar 2020 18:11:14 +0100 Subject: [PATCH] json-rpc: Fix test_txprepare if running with postgres Postgres does not guarantee that the insertion order is the returned order, which leads us to skip outputs that have already been stolen onto the selected utxos set, but not added to it because it isn't confirmed. This may also happen with sqlite3 though it's a lot rarer in that case. --- wallet/wallet.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/wallet/wallet.c b/wallet/wallet.c index 0ed551894..37edd2eae 100644 --- a/wallet/wallet.c +++ b/wallet/wallet.c @@ -403,8 +403,10 @@ static const struct utxo **wallet_select(const tal_t *ctx, struct wallet *w, * confirmation height and that it is below the required * maxheight (current_height - minconf) */ if (maxheight != 0 && - (!u->blockheight || *u->blockheight > maxheight)) + (!u->blockheight || *u->blockheight > maxheight)) { + tal_free(u); continue; + } tal_arr_expand(&utxos, u);