From 7737d29b729d50ab210dbf7a08fe061b48015c8c Mon Sep 17 00:00:00 2001 From: Gregory Sanders Date: Fri, 24 May 2019 10:03:06 -0400 Subject: [PATCH] have peg-in witness creation strip witness for space savings --- src/wallet/rpcwallet.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index c72f8db36af..07dcf33ab17 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5301,6 +5301,11 @@ static UniValue createrawpegin(const JSONRPCRequest& request, T_tx_ref& txBTCRef mtx.vout.push_back(CTxOut(Params().GetConsensus().pegged_asset, value, GetScriptForDestination(wpkhash))); mtx.vout.push_back(CTxOut(Params().GetConsensus().pegged_asset, 0, CScript())); + // Strip witness data for proof inclusion since only TXID-covered fields matters + CDataStream ssTxBack(SER_NETWORK, PROTOCOL_VERSION | SERIALIZE_TRANSACTION_NO_WITNESS); + ssTxBack << txBTC; + std::vector tx_data_stripped(ssTxBack.begin(), ssTxBack.end()); + // Construct pegin proof CScriptWitness pegin_witness; std::vector >& stack = pegin_witness.stack; @@ -5308,7 +5313,7 @@ static UniValue createrawpegin(const JSONRPCRequest& request, T_tx_ref& txBTCRef stack.push_back(std::vector(Params().GetConsensus().pegged_asset.begin(), Params().GetConsensus().pegged_asset.end())); stack.push_back(std::vector(genesisBlockHash.begin(), genesisBlockHash.end())); stack.push_back(std::vector(witness_script.begin(), witness_script.end())); - stack.push_back(txData); + stack.push_back(tx_data_stripped); stack.push_back(txOutProofData); // Peg-in witness isn't valid, even though the block header is(without depth check)