Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/rpcdump.cpp
Show First 20 Lines • Show All 401 Lines • ▼ Show 20 Lines | UniValue importprunedfunds(const Config &config, | ||||
} | } | ||||
.Check(request); | .Check(request); | ||||
CMutableTransaction tx; | CMutableTransaction tx; | ||||
if (!DecodeHexTx(tx, request.params[0].get_str())) { | if (!DecodeHexTx(tx, request.params[0].get_str())) { | ||||
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX decode failed"); | throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX decode failed"); | ||||
} | } | ||||
uint256 txid = tx.GetId(); | uint256 txid = tx.GetId(); | ||||
CWalletTx wtx(pwallet, MakeTransactionRef(std::move(tx))); | |||||
CDataStream ssMB(ParseHexV(request.params[1], "proof"), SER_NETWORK, | CDataStream ssMB(ParseHexV(request.params[1], "proof"), SER_NETWORK, | ||||
PROTOCOL_VERSION); | PROTOCOL_VERSION); | ||||
CMerkleBlock merkleBlock; | CMerkleBlock merkleBlock; | ||||
ssMB >> merkleBlock; | ssMB >> merkleBlock; | ||||
// Search partial merkle tree in proof for our transaction and index in | // Search partial merkle tree in proof for our transaction and index in | ||||
// valid block | // valid block | ||||
Show All 19 Lines | if ((it = std::find(vMatch.begin(), vMatch.end(), txid)) == vMatch.end()) { | ||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, | throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, | ||||
"Transaction given doesn't exist in proof"); | "Transaction given doesn't exist in proof"); | ||||
} | } | ||||
size_t txnIndex = vIndex[it - vMatch.begin()]; | size_t txnIndex = vIndex[it - vMatch.begin()]; | ||||
CWalletTx::Confirmation confirm(CWalletTx::Status::CONFIRMED, height, | CWalletTx::Confirmation confirm(CWalletTx::Status::CONFIRMED, height, | ||||
merkleBlock.header.GetHash(), txnIndex); | merkleBlock.header.GetHash(), txnIndex); | ||||
wtx.m_confirm = confirm; | |||||
if (pwallet->IsMine(*wtx.tx)) { | CTransactionRef tx_ref = MakeTransactionRef(tx); | ||||
pwallet->AddToWallet(wtx, false); | if (pwallet->IsMine(*tx_ref)) { | ||||
pwallet->AddToWallet(std::move(tx_ref), confirm); | |||||
return NullUniValue; | return NullUniValue; | ||||
} | } | ||||
throw JSONRPCError( | throw JSONRPCError( | ||||
RPC_INVALID_ADDRESS_OR_KEY, | RPC_INVALID_ADDRESS_OR_KEY, | ||||
"No addresses in wallet correspond to included transaction"); | "No addresses in wallet correspond to included transaction"); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 1,879 Lines • Show Last 20 Lines |