wallet rpc: return final tx hex from walletprocesspsbt if complete

This commit is contained in:
Matthew Zipkin
2023-09-05 08:45:07 -04:00
parent ecab855838
commit e3d484b603
2 changed files with 24 additions and 6 deletions

View File

@@ -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;
},