From 5663ecc599ef1a167d2ec318121bbbc9946fd9c2 Mon Sep 17 00:00:00 2001 From: lisa neigut Date: Thu, 29 Aug 2019 10:54:26 -0500 Subject: [PATCH] listfunds: add 'blockheight' for confirmed transactions Needed to calculate the value of all inputs for 'all' in externalized fundchannel --- CHANGELOG.md | 1 + wallet/wallet.c | 2 +- wallet/walletrpc.c | 5 +++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d70c29b43..bf1c39d7d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ### Added +- JSON API: `listfunds` now lists a blockheight for confirmed transactions ### Changed diff --git a/wallet/wallet.c b/wallet/wallet.c index ccfdeb86c..9e86688ce 100644 --- a/wallet/wallet.c +++ b/wallet/wallet.c @@ -310,7 +310,7 @@ static const struct utxo **wallet_select(const tal_t *ctx, struct wallet *w, /* If we require confirmations check that we have a * confirmation height and that it is below the required - * maxheight (current_height - minconf */ + * maxheight (current_height - minconf) */ if (maxheight != 0 && (!u->blockheight || *u->blockheight > maxheight)) continue; diff --git a/wallet/walletrpc.c b/wallet/walletrpc.c index efe3f37e0..e7bbf4718 100644 --- a/wallet/walletrpc.c +++ b/wallet/walletrpc.c @@ -629,9 +629,10 @@ static struct command_result *json_listfunds(struct command *cmd, if (utxos[i]->spendheight) json_add_string(response, "status", "spent"); - else if (utxos[i]->blockheight) + else if (utxos[i]->blockheight) { json_add_string(response, "status", "confirmed"); - else + json_add_num(response, "blockheight", *utxos[i]->blockheight); + } else json_add_string(response, "status", "unconfirmed"); json_object_end(response);