Skip to content

Commit

Permalink
listfunds: add "redeemscript" field.
Browse files Browse the repository at this point in the history
You'd need this if you ever wanted to make your own PSBT.

Signed-off-by: Rusty Russell <[email protected]>
Changelog-Added: `listfunds` now has a `redeemscript` field for p2sh-wrapped outputs.
  • Loading branch information
rustyrussell committed Jul 17, 2020
1 parent 455d5df commit 9d47b7b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions doc/lightning-listfunds.7

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions doc/lightning-listfunds.7.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Each entry in *outputs* will include:
appended)
- *address*
- *scriptpubkey* (the ScriptPubkey of the output, in hex)
- *redeemscript* (the redeemscript of the output, in hex, only if it's p2sh-wrapped)
- *status* (whether *unconfirmed*, *confirmed*, or *spent*)
- *reserved* (whether this is UTXO is currently reserved for an in-flight tx)

Expand Down
8 changes: 8 additions & 0 deletions wallet/walletrpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -868,6 +868,14 @@ static void json_add_utxo(struct json_stream *response,
json_add_amount_sat_compat(response, utxo->amount,
"value", "amount_msat");

if (utxo->is_p2sh) {
struct pubkey key;
bip32_pubkey(wallet->bip32_base, &key, utxo->keyindex);

json_add_hex_talarr(response, "redeemscript",
bitcoin_redeem_p2sh_p2wpkh(tmpctx, &key));
}

if (utxo->scriptPubkey != NULL) {
json_add_hex_talarr(response, "scriptpubkey", utxo->scriptPubkey);
out = encode_scriptpubkey_to_addr(
Expand Down

0 comments on commit 9d47b7b

Please sign in to comment.