From 7744c4152185ca2765bc45f008cd4bda929fcaab Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Wed, 19 Sep 2018 12:26:54 +0930 Subject: [PATCH] listpeers: add 'scratch_txid' for the tx we would broadcast if necessary. Signed-off-by: Rusty Russell --- CHANGELOG.md | 2 ++ lightningd/peer_control.c | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 39b11ed80..db1a501cb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ### Added +- JSON API: `listpeers` has new field `scratch_txid`: the latest tx in channel. + ### Changed ### Deprecated diff --git a/lightningd/peer_control.c b/lightningd/peer_control.c index cba4f5130..4dc9fa945 100644 --- a/lightningd/peer_control.c +++ b/lightningd/peer_control.c @@ -642,6 +642,12 @@ static void json_add_peer(struct lightningd *ld, json_object_start(response, NULL); json_add_string(response, "state", channel_state_name(channel)); + if (channel->last_tx) { + struct bitcoin_txid txid; + bitcoin_txid(channel->last_tx, &txid); + + json_add_txid(response, "scratch_txid", &txid); + } if (channel->owner) json_add_string(response, "owner", channel->owner->name);