Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/rpcwallet.cpp
Show First 20 Lines • Show All 2,720 Lines • ▼ Show 20 Lines | static UniValue listsinceblock(const Config &config, | ||||
// provided was in a deactivated chain. | // provided was in a deactivated chain. | ||||
const CBlockIndex *pindex = nullptr; | const CBlockIndex *pindex = nullptr; | ||||
// Block index of the specified block, even if it's in a deactivated chain. | // Block index of the specified block, even if it's in a deactivated chain. | ||||
const CBlockIndex *paltindex = nullptr; | const CBlockIndex *paltindex = nullptr; | ||||
int target_confirms = 1; | int target_confirms = 1; | ||||
isminefilter filter = ISMINE_SPENDABLE; | isminefilter filter = ISMINE_SPENDABLE; | ||||
if (!request.params[0].isNull() && !request.params[0].get_str().empty()) { | if (!request.params[0].isNull() && !request.params[0].get_str().empty()) { | ||||
BlockHash blockId(uint256S(request.params[0].get_str())); | BlockHash blockId(ParseHashV(request.params[0], "blockhash")); | ||||
paltindex = pindex = LookupBlockIndex(blockId); | paltindex = pindex = LookupBlockIndex(blockId); | ||||
if (!pindex) { | if (!pindex) { | ||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found"); | throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found"); | ||||
} | } | ||||
if (chainActive[pindex->nHeight] != pindex) { | if (chainActive[pindex->nHeight] != pindex) { | ||||
// the block being asked for is a part of a deactivated chain; | // the block being asked for is a part of a deactivated chain; | ||||
// we don't want to depend on its perceived height in the block | // we don't want to depend on its perceived height in the block | ||||
// chain, we want to instead use the last common ancestor | // chain, we want to instead use the last common ancestor | ||||
▲ Show 20 Lines • Show All 165 Lines • ▼ Show 20 Lines | static UniValue gettransaction(const Config &config, | ||||
// Make sure the results are valid at least up to the most recent block | // Make sure the results are valid at least up to the most recent block | ||||
// the user could have gotten from another RPC command prior to now | // the user could have gotten from another RPC command prior to now | ||||
pwallet->BlockUntilSyncedToCurrentChain(); | pwallet->BlockUntilSyncedToCurrentChain(); | ||||
auto locked_chain = pwallet->chain().lock(); | auto locked_chain = pwallet->chain().lock(); | ||||
LOCK(pwallet->cs_wallet); | LOCK(pwallet->cs_wallet); | ||||
TxId txid; | TxId txid(ParseHashV(request.params[0], "txid")); | ||||
txid.SetHex(request.params[0].get_str()); | |||||
isminefilter filter = ISMINE_SPENDABLE; | isminefilter filter = ISMINE_SPENDABLE; | ||||
if (!request.params[1].isNull() && request.params[1].get_bool()) { | if (!request.params[1].isNull() && request.params[1].get_bool()) { | ||||
filter = filter | ISMINE_WATCH_ONLY; | filter = filter | ISMINE_WATCH_ONLY; | ||||
} | } | ||||
UniValue entry(UniValue::VOBJ); | UniValue entry(UniValue::VOBJ); | ||||
auto it = pwallet->mapWallet.find(txid); | auto it = pwallet->mapWallet.find(txid); | ||||
▲ Show 20 Lines • Show All 61 Lines • ▼ Show 20 Lines | static UniValue abandontransaction(const Config &config, | ||||
// Make sure the results are valid at least up to the most recent block | // Make sure the results are valid at least up to the most recent block | ||||
// the user could have gotten from another RPC command prior to now | // the user could have gotten from another RPC command prior to now | ||||
pwallet->BlockUntilSyncedToCurrentChain(); | pwallet->BlockUntilSyncedToCurrentChain(); | ||||
auto locked_chain = pwallet->chain().lock(); | auto locked_chain = pwallet->chain().lock(); | ||||
LOCK(pwallet->cs_wallet); | LOCK(pwallet->cs_wallet); | ||||
TxId txid; | TxId txid(ParseHashV(request.params[0], "txid")); | ||||
txid.SetHex(request.params[0].get_str()); | |||||
if (!pwallet->mapWallet.count(txid)) { | if (!pwallet->mapWallet.count(txid)) { | ||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, | throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, | ||||
"Invalid or non-wallet transaction id"); | "Invalid or non-wallet transaction id"); | ||||
} | } | ||||
if (!pwallet->AbandonTransaction(*locked_chain, txid)) { | if (!pwallet->AbandonTransaction(*locked_chain, txid)) { | ||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, | throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, | ||||
▲ Show 20 Lines • Show All 488 Lines • ▼ Show 20 Lines | static UniValue lockunspent(const Config &config, | ||||
for (size_t idx = 0; idx < output_params.size(); idx++) { | for (size_t idx = 0; idx < output_params.size(); idx++) { | ||||
const UniValue &o = output_params[idx].get_obj(); | const UniValue &o = output_params[idx].get_obj(); | ||||
RPCTypeCheckObj(o, { | RPCTypeCheckObj(o, { | ||||
{"txid", UniValueType(UniValue::VSTR)}, | {"txid", UniValueType(UniValue::VSTR)}, | ||||
{"vout", UniValueType(UniValue::VNUM)}, | {"vout", UniValueType(UniValue::VNUM)}, | ||||
}); | }); | ||||
const std::string &strTxId = find_value(o, "txid").get_str(); | |||||
if (!IsHex(strTxId)) { | |||||
throw JSONRPCError(RPC_INVALID_PARAMETER, | |||||
"Invalid parameter, expected hex txid"); | |||||
} | |||||
const int nOutput = find_value(o, "vout").get_int(); | const int nOutput = find_value(o, "vout").get_int(); | ||||
if (nOutput < 0) { | if (nOutput < 0) { | ||||
throw JSONRPCError(RPC_INVALID_PARAMETER, | throw JSONRPCError(RPC_INVALID_PARAMETER, | ||||
"Invalid parameter, vout must be positive"); | "Invalid parameter, vout must be positive"); | ||||
} | } | ||||
const TxId txid(uint256S(strTxId)); | const TxId txid(ParseHashO(o, "txid")); | ||||
const auto it = pwallet->mapWallet.find(txid); | const auto it = pwallet->mapWallet.find(txid); | ||||
if (it == pwallet->mapWallet.end()) { | if (it == pwallet->mapWallet.end()) { | ||||
throw JSONRPCError(RPC_INVALID_PARAMETER, | throw JSONRPCError(RPC_INVALID_PARAMETER, | ||||
"Invalid parameter, unknown transaction"); | "Invalid parameter, unknown transaction"); | ||||
} | } | ||||
const COutPoint output(txid, nOutput); | const COutPoint output(txid, nOutput); | ||||
const CWalletTx &trans = it->second; | const CWalletTx &trans = it->second; | ||||
▲ Show 20 Lines • Show All 2,127 Lines • Show Last 20 Lines |