Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/rpcwallet.cpp
Show First 20 Lines • Show All 3,017 Lines • ▼ Show 20 Lines | for (size_t idx = 0; idx < output_params.size(); idx++) { | ||||
} | } | ||||
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 COutPoint outpt(uint256S(txid), nOutput); | const COutPoint output(uint256S(txid), nOutput); | ||||
const auto it = pwallet->mapWallet.find(outpt.GetTxId()); | const auto it = pwallet->mapWallet.find(output.GetTxId()); | ||||
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 CWalletTx &trans = it->second; | const CWalletTx &trans = it->second; | ||||
if (outpt.GetN() >= trans.tx->vout.size()) { | if (output.GetN() >= trans.tx->vout.size()) { | ||||
throw JSONRPCError(RPC_INVALID_PARAMETER, | throw JSONRPCError(RPC_INVALID_PARAMETER, | ||||
"Invalid parameter, vout index out of bounds"); | "Invalid parameter, vout index out of bounds"); | ||||
} | } | ||||
if (pwallet->IsSpent(outpt)) { | if (pwallet->IsSpent(output)) { | ||||
throw JSONRPCError(RPC_INVALID_PARAMETER, | throw JSONRPCError(RPC_INVALID_PARAMETER, | ||||
"Invalid parameter, expected unspent output"); | "Invalid parameter, expected unspent output"); | ||||
} | } | ||||
const bool is_locked = pwallet->IsLockedCoin(outpt); | const bool is_locked = pwallet->IsLockedCoin(output); | ||||
if (fUnlock && !is_locked) { | if (fUnlock && !is_locked) { | ||||
throw JSONRPCError(RPC_INVALID_PARAMETER, | throw JSONRPCError(RPC_INVALID_PARAMETER, | ||||
"Invalid parameter, expected locked output"); | "Invalid parameter, expected locked output"); | ||||
} | } | ||||
if (!fUnlock && is_locked) { | if (!fUnlock && is_locked) { | ||||
throw JSONRPCError(RPC_INVALID_PARAMETER, | throw JSONRPCError(RPC_INVALID_PARAMETER, | ||||
"Invalid parameter, output already locked"); | "Invalid parameter, output already locked"); | ||||
} | } | ||||
outputs.push_back(outpt); | outputs.push_back(output); | ||||
} | } | ||||
// Atomically set (un)locked status for the outputs. | // Atomically set (un)locked status for the outputs. | ||||
for (const COutPoint &outpt : outputs) { | for (const COutPoint &output : outputs) { | ||||
if (fUnlock) { | if (fUnlock) { | ||||
pwallet->UnlockCoin(outpt); | pwallet->UnlockCoin(output); | ||||
} else { | } else { | ||||
pwallet->LockCoin(outpt); | pwallet->LockCoin(output); | ||||
} | } | ||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
static UniValue listlockunspent(const Config &config, | static UniValue listlockunspent(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
▲ Show 20 Lines • Show All 1,225 Lines • Show Last 20 Lines |