Skip to content

Commit 8ece8e0

Browse files
committed
Show peg-in info in decodepsbt
1 parent 646e76f commit 8ece8e0

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

src/rpc/rawtransaction.cpp

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1660,6 +1660,10 @@ UniValue decodepsbt(const JSONRPCRequest& request)
16601660
" \"value_blinding_factor\": \"hex\" , (string) The value blinding factor from the output being spent\n"
16611661
" \"asset\": \"hex\" , (string) The (unblinded) asset id of the input\n"
16621662
" \"asset_blinding_factor\": \"hex\" , (string) The asset blinding factor from the output being spent\n"
1663+
" \"pegin_bitcoin_tx\": \"hex\", (string) The tx providing the peg-in in the format of the getrawtransaction RPC.\n"
1664+
" \"pegin_claim_script\": \"hex\", (string) The claim script for the peg-in input\n"
1665+
" \"pegin_txout_proof\": \"hex\", (string) The tx providing the peg-in input\n"
1666+
" \"pegin_genesis_hash\": \"hex\", (string) The hash of the genesis block for this peg-in\n"
16631667
" \"unknown\" : { (json object) The unknown input fields\n"
16641668
" \"key\" : \"value\" (key-value pair) An unknown key-value pair\n"
16651669
" ...\n"
@@ -1836,6 +1840,49 @@ UniValue decodepsbt(const JSONRPCRequest& request)
18361840
in.pushKV("asset_blinding_factor", input.asset_blinding_factor.GetHex());
18371841
}
18381842

1843+
// Peg-in stuff
1844+
if (Params().GetConsensus().ParentChainHasPow()) {
1845+
if (input.peg_in_tx.which() > 0) {
1846+
const Sidechain::Bitcoin::CTransactionRef& btc_peg_in_tx = boost::get<Sidechain::Bitcoin::CTransactionRef>(input.peg_in_tx);
1847+
if (btc_peg_in_tx) {
1848+
CDataStream ss_tx(SER_NETWORK, PROTOCOL_VERSION | SERIALIZE_TRANSACTION_NO_WITNESS);
1849+
ss_tx << btc_peg_in_tx;
1850+
in.pushKV("pegin_bitcoin_tx", HexStr(ss_tx.begin(), ss_tx.end()));
1851+
}
1852+
}
1853+
if (input.txout_proof.which() > 0) {
1854+
const Sidechain::Bitcoin::CMerkleBlock& btc_txout_proof = boost::get<Sidechain::Bitcoin::CMerkleBlock>(input.txout_proof);
1855+
if (!btc_txout_proof.header.IsNull()) {
1856+
CDataStream ss_mb(SER_NETWORK, PROTOCOL_VERSION | SERIALIZE_TRANSACTION_NO_WITNESS);
1857+
ss_mb << btc_txout_proof;
1858+
in.pushKV("pegin_txout_proof", HexStr(ss_mb.begin(), ss_mb.end()));
1859+
}
1860+
}
1861+
} else {
1862+
if (input.peg_in_tx.which() > 0) {
1863+
const CTransactionRef& elem_peg_in_tx = boost::get<CTransactionRef>(input.peg_in_tx);
1864+
if (elem_peg_in_tx) {
1865+
CDataStream ss_tx(SER_NETWORK, PROTOCOL_VERSION | SERIALIZE_TRANSACTION_NO_WITNESS);
1866+
ss_tx << elem_peg_in_tx;
1867+
in.pushKV("pegin_bitcoin_tx", HexStr(ss_tx.begin(), ss_tx.end()));
1868+
}
1869+
}
1870+
if (input.txout_proof.which() > 0) {
1871+
const CMerkleBlock& elem_txout_proof = boost::get<CMerkleBlock>(input.txout_proof);
1872+
if (!elem_txout_proof.header.IsNull()) {
1873+
CDataStream ss_mb(SER_NETWORK, PROTOCOL_VERSION | SERIALIZE_TRANSACTION_NO_WITNESS);
1874+
ss_mb << elem_txout_proof;
1875+
in.pushKV("pegin_txout_proof", HexStr(ss_mb.begin(), ss_mb.end()));
1876+
}
1877+
}
1878+
}
1879+
if (!input.claim_script.empty()) {
1880+
in.pushKV("pegin_claim_script", HexStr(input.claim_script.begin(), input.claim_script.end()));
1881+
}
1882+
if (!input.genesis_hash.IsNull()) {
1883+
in.pushKV("pegin_genesis_hash", input.genesis_hash.GetHex());
1884+
}
1885+
18391886
// Unknown data
18401887
if (input.unknown.size() > 0) {
18411888
UniValue unknowns(UniValue::VOBJ);

0 commit comments

Comments
 (0)