diff options
author | Andrew Chow <achow101-github@achow101.com> | 2021-02-16 13:22:49 -0500 |
---|---|---|
committer | Andrew Chow <achow101-github@achow101.com> | 2021-02-16 15:49:28 -0500 |
commit | 0997019e7681efb00847a7246c15ac8f235128d8 (patch) | |
tree | 2d7cd02d2747afa1abb642c8f68b6e58944b0656 /src | |
parent | 3c9d9d21e195ccfb28353c14a9f38f5366c98c8e (diff) |
Disallow sendtoaddress and sendmany when private keys disabled
Diffstat (limited to 'src')
-rw-r--r-- | src/wallet/rpcwallet.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 46de273d63..e385ccfff2 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -400,6 +400,12 @@ UniValue SendMoney(CWallet* const pwallet, const CCoinControl &coin_control, std { EnsureWalletIsUnlocked(pwallet); + // This function is only used by sendtoaddress and sendmany. + // This should always try to sign, if we don't have private keys, don't try to do anything here. + if (pwallet->IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS)) { + throw JSONRPCError(RPC_WALLET_ERROR, "Error: Private keys are disabled for this wallet"); + } + // Shuffle recipient list std::shuffle(recipients.begin(), recipients.end(), FastRandomContext()); @@ -409,7 +415,7 @@ UniValue SendMoney(CWallet* const pwallet, const CCoinControl &coin_control, std bilingual_str error; CTransactionRef tx; FeeCalculation fee_calc_out; - bool fCreated = pwallet->CreateTransaction(recipients, tx, nFeeRequired, nChangePosRet, error, coin_control, fee_calc_out, !pwallet->IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS)); + const bool fCreated = pwallet->CreateTransaction(recipients, tx, nFeeRequired, nChangePosRet, error, coin_control, fee_calc_out, true); if (!fCreated) { throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, error.original); } |