diff --git a/doc/lightning-listpeerchannels.7.md b/doc/lightning-listpeerchannels.7.md index d85ed193c..cfc0d33b1 100644 --- a/doc/lightning-listpeerchannels.7.md +++ b/doc/lightning-listpeerchannels.7.md @@ -56,7 +56,7 @@ On success, an object containing **channels** is returned. It is an array of ob - **total\_funding\_msat** (msat): total amount in the channel - **splice\_amount** (integer): The amouont of sats we're splicing in or out *(added v23.08)* - **our\_funding\_msat** (msat): amount we have in the channel - - **scratch\_txid** (txid): The commitment transaction txid we would use if we went onchain now + - **scratch\_txid** (txid, optional): The commitment transaction txid we would use if we went onchain now - **close\_to** (hex, optional): scriptPubkey which we have to close to if we mutual close - **private** (boolean, optional): if True, we will not announce this channel - **closer** (string, optional): Who initiated the channel close (only present if closing) (one of "local", "remote") @@ -202,4 +202,4 @@ Main web site: Lightning RFC site (BOLT \#9): -[comment]: # ( SHA256STAMP:d8f5d19a70fa3e8718e96369510ab8c9b28a0c0b626eb10321bfccb1cd7dbc0b) +[comment]: # ( SHA256STAMP:c4507febb0d592ac386f2e8bedbc88ab77d93f780e2d534d6c8d8064afbd6ee6) diff --git a/doc/schemas/listpeerchannels.schema.json b/doc/schemas/listpeerchannels.schema.json index e89e0ffe1..64dc2a4ff 100644 --- a/doc/schemas/listpeerchannels.schema.json +++ b/doc/schemas/listpeerchannels.schema.json @@ -159,8 +159,7 @@ "feerate", "total_funding_msat", "splice_amount", - "our_funding_msat", - "scratch_txid" + "our_funding_msat" ], "properties": { "funding_txid": { diff --git a/lightningd/peer_control.c b/lightningd/peer_control.c index eead64b27..cabac68dc 100644 --- a/lightningd/peer_control.c +++ b/lightningd/peer_control.c @@ -939,8 +939,10 @@ static void json_add_channel(struct lightningd *ld, "splice_amount", inflight->funding->splice_amnt); /* Add the expected commitment tx id also */ - bitcoin_txid(inflight->last_tx, &txid); - json_add_txid(response, "scratch_txid", &txid); + if (inflight->last_tx) { + bitcoin_txid(inflight->last_tx, &txid); + json_add_txid(response, "scratch_txid", &txid); + } json_object_end(response); } json_array_end(response);