aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrew Chow <github@achow101.com>2023-09-12 12:18:52 -0400
committerAndrew Chow <github@achow101.com>2023-09-12 12:28:13 -0400
commit8f9c74cb11d2016c84eea037533c1a131745fdc8 (patch)
treecedf7acfca007d83e88b34a9d9cb6008eaebaa1e /src
parent7649431637441d0e236f33d67eb196bfc33a13a7 (diff)
parent2e249b922762f19d6ae61edaad062f31bc2849f3 (diff)
downloadbitcoin-8f9c74cb11d2016c84eea037533c1a131745fdc8.tar.xz
Merge bitcoin/bitcoin#28414: wallet rpc: return final tx hex from walletprocesspsbt if complete
2e249b922762f19d6ae61edaad062f31bc2849f3 doc: add release note for PR #28414 (Matthew Zipkin) 4614332fc4514f63fcbe9e6de507f7bb9b7e87e9 test: remove unnecessary finalizepsbt rpc calls (ismaelsadeeq) e3d484b603abff69c6ebfca5cfb78cf82743d090 wallet rpc: return final tx hex from walletprocesspsbt if complete (Matthew Zipkin) Pull request description: See https://github.com/bitcoin/bitcoin/pull/28363#discussion_r1315753887 `walletprocesspsbt` currently returns a base64-encoded PSBT and a boolean indicating if the tx is "complete". If it is complete, the base64 PSBT can be finalized with `finalizepsbt` which returns the hex-encoded transaction suitable for `sendrawtransaction`. With this patch, `walletprocesspsbt` return object will ALSO include the broadcast-able hex string if the tx is already final. This saves users the extra step of calling `finalizepsbt` assuming they have already inspected and approve the transaction from earlier steps. ACKs for top commit: ismaelsadeeq: re ACK 2e249b922762f19d6ae61edaad062f31bc2849f3 BrandonOdiwuor: re ACK 2e249b9 Randy808: Tested ACK 2e249b922762f19d6ae61edaad062f31bc2849f3 achow101: ACK 2e249b922762f19d6ae61edaad062f31bc2849f3 ishaanam: ACK 2e249b922762f19d6ae61edaad062f31bc2849f3 Tree-SHA512: 229c1103265a9b4248f080935a7ad5607c3be3f9a096a9ab6554093b2cd8aa8b4d1fa55b1b97d3925ba208dbc3ccba4e4d37c40e1491db0d27ba3d9fe98f931e
Diffstat (limited to 'src')
-rw-r--r--src/wallet/rpc/spend.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/wallet/rpc/spend.cpp b/src/wallet/rpc/spend.cpp
index 0c2be26ddf..c4206e9897 100644
--- a/src/wallet/rpc/spend.cpp
+++ b/src/wallet/rpc/spend.cpp
@@ -1566,6 +1566,7 @@ RPCHelpMan walletprocesspsbt()
{
{RPCResult::Type::STR, "psbt", "The base64-encoded partially signed transaction"},
{RPCResult::Type::BOOL, "complete", "If the transaction has a complete set of signatures"},
+ {RPCResult::Type::STR_HEX, "hex", /*optional=*/true, "The hex-encoded network transaction if complete"},
}
},
RPCExamples{
@@ -1609,6 +1610,14 @@ RPCHelpMan walletprocesspsbt()
ssTx << psbtx;
result.pushKV("psbt", EncodeBase64(ssTx.str()));
result.pushKV("complete", complete);
+ if (complete) {
+ CMutableTransaction mtx;
+ // Returns true if complete, which we already think it is.
+ CHECK_NONFATAL(FinalizeAndExtractPSBT(psbtx, mtx));
+ CDataStream ssTx_final(SER_NETWORK, PROTOCOL_VERSION);
+ ssTx_final << mtx;
+ result.pushKV("hex", HexStr(ssTx_final));
+ }
return result;
},