Skip to content

Commit c405207

Browse files
committed
rpc: descriptorprocesspsbt return hex encoded tx
If processed psbt is complete return hex encoded network transaction in the output.
1 parent f1a9fd6 commit c405207

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/rpc/rawtransaction.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1949,6 +1949,7 @@ RPCHelpMan descriptorprocesspsbt()
19491949
{
19501950
{RPCResult::Type::STR, "psbt", "The base64-encoded partially signed transaction"},
19511951
{RPCResult::Type::BOOL, "complete", "If the transaction has a complete set of signatures"},
1952+
{RPCResult::Type::STR_HEX, "hex", /*optional=*/true, "The hex-encoded network transaction if complete"},
19521953
}
19531954
},
19541955
RPCExamples{
@@ -1989,7 +1990,14 @@ RPCHelpMan descriptorprocesspsbt()
19891990

19901991
result.pushKV("psbt", EncodeBase64(ssTx));
19911992
result.pushKV("complete", complete);
1992-
1993+
if (complete) {
1994+
CMutableTransaction mtx;
1995+
PartiallySignedTransaction psbtx_copy = psbtx;
1996+
CHECK_NONFATAL(FinalizeAndExtractPSBT(psbtx_copy, mtx));
1997+
CDataStream ssTx_final(SER_NETWORK, PROTOCOL_VERSION);
1998+
ssTx_final << mtx;
1999+
result.pushKV("hex", HexStr(ssTx_final));
2000+
}
19932001
return result;
19942002
},
19952003
};

0 commit comments

Comments
 (0)