Skip to content

Commit 3a1c20b

Browse files
committed
Add raw transaction hex to gettransaction wallet RPC
This allows getting raw transaction data from the wallet even if the transaction is no longer in the blockchain / mempool (for example if it got orphaned due to malleability abuse).
1 parent ea06265 commit 3a1c20b

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/rpcwallet.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1448,7 +1448,8 @@ Value gettransaction(const Array& params, bool fHelp)
14481448
" \"amount\" : x.xxx (numeric) The amount in btc\n"
14491449
" }\n"
14501450
" ,...\n"
1451-
" ]\n"
1451+
" ],\n"
1452+
" \"hex\" : \"data\" (string) Raw data for transaction\n"
14521453
"}\n"
14531454

14541455
"\nbExamples\n"
@@ -1479,6 +1480,11 @@ Value gettransaction(const Array& params, bool fHelp)
14791480
ListTransactions(wtx, "*", 0, false, details);
14801481
entry.push_back(Pair("details", details));
14811482

1483+
CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION);
1484+
ssTx << wtx;
1485+
string strHex = HexStr(ssTx.begin(), ssTx.end());
1486+
entry.push_back(Pair("hex", strHex));
1487+
14821488
return entry;
14831489
}
14841490

0 commit comments

Comments
 (0)