From a494e1c51c7f54ba353b02a7e470b0df0c0e7bbe Mon Sep 17 00:00:00 2001 From: CryptoManiac Date: Fri, 19 Feb 2016 00:22:21 +0300 Subject: [PATCH] Wallet core: remove SendMoneyToDestination --- src/rpcwallet.cpp | 12 ++++++++++-- src/wallet.cpp | 26 ++++++-------------------- src/wallet.h | 1 - 3 files changed, 16 insertions(+), 23 deletions(-) diff --git a/src/rpcwallet.cpp b/src/rpcwallet.cpp index 8b3780e..ca64fff 100644 --- a/src/rpcwallet.cpp +++ b/src/rpcwallet.cpp @@ -343,7 +343,11 @@ Value sendtoaddress(const Array& params, bool fHelp) if (pwalletMain->IsLocked()) throw JSONRPCError(RPC_WALLET_UNLOCK_NEEDED, "Error: Please enter the wallet passphrase with walletpassphrase first."); - string strError = pwalletMain->SendMoneyToDestination(address.Get(), nAmount, wtx); + // Parse Bitcoin address + CScript scriptPubKey; + scriptPubKey.SetDestination(address.Get()); + + string strError = pwalletMain->SendMoney(scriptPubKey, nAmount, wtx); if (strError != "") throw JSONRPCError(RPC_WALLET_ERROR, strError); @@ -721,8 +725,12 @@ Value sendfrom(const Array& params, bool fHelp) if (nAmount > nBalance) throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, "Account has insufficient funds"); + // Parse Bitcoin address + CScript scriptPubKey; + scriptPubKey.SetDestination(address.Get()); + // Send - string strError = pwalletMain->SendMoneyToDestination(address.Get(), nAmount, wtx); + string strError = pwalletMain->SendMoney(scriptPubKey, nAmount, wtx); if (strError != "") throw JSONRPCError(RPC_WALLET_ERROR, strError); diff --git a/src/wallet.cpp b/src/wallet.cpp index 5c46a1b..5eed75c 100644 --- a/src/wallet.cpp +++ b/src/wallet.cpp @@ -2101,6 +2101,12 @@ bool CWallet::CommitTransaction(CWalletTx& wtxNew, CReserveKey& reservekey) string CWallet::SendMoney(CScript scriptPubKey, int64_t nValue, CWalletTx& wtxNew, bool fAskFee) { + // Check amount + if (nValue <= 0) + return _("Invalid amount"); + if (nValue + nTransactionFee > GetBalance()) + return _("Insufficient funds"); + CReserveKey reservekey(this); int64_t nFeeRequired; @@ -2136,26 +2142,6 @@ string CWallet::SendMoney(CScript scriptPubKey, int64_t nValue, CWalletTx& wtxNe return ""; } - - -string CWallet::SendMoneyToDestination(const CTxDestination& address, int64_t nValue, CWalletTx& wtxNew, bool fAskFee) -{ - // Check amount - if (nValue <= 0) - return _("Invalid amount"); - if (nValue + nTransactionFee > GetBalance()) - return _("Insufficient funds"); - - // Parse Bitcoin address - CScript scriptPubKey; - scriptPubKey.SetDestination(address); - - return SendMoney(scriptPubKey, nValue, wtxNew, fAskFee); -} - - - - DBErrors CWallet::LoadWallet(bool& fFirstRunRet) { if (!fFileBacked) diff --git a/src/wallet.h b/src/wallet.h index 20abe44..bc8afa8 100644 --- a/src/wallet.h +++ b/src/wallet.h @@ -229,7 +229,6 @@ public: bool MergeCoins(const int64_t& nAmount, const int64_t& nMinValue, const int64_t& nMaxValue, std::list& listMerged); std::string SendMoney(CScript scriptPubKey, int64_t nValue, CWalletTx& wtxNew, bool fAskFee=false); - std::string SendMoneyToDestination(const CTxDestination &address, int64_t nValue, CWalletTx& wtxNew, bool fAskFee=false); bool NewKeyPool(unsigned int nSize = 0); bool TopUpKeyPool(unsigned int nSize = 0); -- 1.7.1