Skip to content

Commit e832ab7

Browse files
committed
Rename SendMoneyToDestination to SendMoney.
Get rid of SendMoney and replace it by the functionality of SendMoneyToDestination. This cleans up the code, since only SendMoneyToDestination was actually used (SendMoney internally from this routine).
1 parent 4ed2315 commit e832ab7

File tree

3 files changed

+19
-25
lines changed

3 files changed

+19
-25
lines changed

src/rpcwallet.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ Value sendtoaddress(const Array& params, bool fHelp)
346346

347347
EnsureWalletIsUnlocked();
348348

349-
string strError = pwalletMain->SendMoneyToDestination(address.Get(), nAmount, wtx);
349+
string strError = pwalletMain->SendMoney(address.Get(), nAmount, wtx);
350350
if (strError != "")
351351
throw JSONRPCError(RPC_WALLET_ERROR, strError);
352352

@@ -786,7 +786,7 @@ Value sendfrom(const Array& params, bool fHelp)
786786
throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, "Account has insufficient funds");
787787

788788
// Send
789-
string strError = pwalletMain->SendMoneyToDestination(address.Get(), nAmount, wtx);
789+
string strError = pwalletMain->SendMoney(address.Get(), nAmount, wtx);
790790
if (strError != "")
791791
throw JSONRPCError(RPC_WALLET_ERROR, strError);
792792

src/wallet.cpp

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1487,26 +1487,36 @@ bool CWallet::CommitTransaction(CWalletTx& wtxNew, CReserveKey& reservekey)
14871487

14881488

14891489

1490-
string CWallet::SendMoney(CScript scriptPubKey, int64_t nValue, CWalletTx& wtxNew)
1490+
string CWallet::SendMoney(const CTxDestination &address, int64_t nValue, CWalletTx& wtxNew)
14911491
{
1492-
CReserveKey reservekey(this);
1493-
int64_t nFeeRequired;
1492+
// Check amount
1493+
if (nValue <= 0)
1494+
return _("Invalid amount");
1495+
if (nValue > GetBalance())
1496+
return _("Insufficient funds");
14941497

1498+
string strError;
14951499
if (IsLocked())
14961500
{
1497-
string strError = _("Error: Wallet locked, unable to create transaction!");
1501+
strError = _("Error: Wallet locked, unable to create transaction!");
14981502
LogPrintf("SendMoney() : %s", strError);
14991503
return strError;
15001504
}
1501-
string strError;
1505+
1506+
// Parse Bitcoin address
1507+
CScript scriptPubKey;
1508+
scriptPubKey.SetDestination(address);
1509+
1510+
// Create and send the transaction
1511+
CReserveKey reservekey(this);
1512+
int64_t nFeeRequired;
15021513
if (!CreateTransaction(scriptPubKey, nValue, wtxNew, reservekey, nFeeRequired, strError))
15031514
{
15041515
if (nValue + nFeeRequired > GetBalance())
15051516
strError = strprintf(_("Error: This transaction requires a transaction fee of at least %s because of its amount, complexity, or use of recently received funds!"), FormatMoney(nFeeRequired));
15061517
LogPrintf("SendMoney() : %s\n", strError);
15071518
return strError;
15081519
}
1509-
15101520
if (!CommitTransaction(wtxNew, reservekey))
15111521
return _("Error: The transaction was rejected! This might happen if some of the coins in your wallet were already spent, such as if you used a copy of wallet.dat and coins were spent in the copy but not marked as spent here.");
15121522

@@ -1515,21 +1525,6 @@ string CWallet::SendMoney(CScript scriptPubKey, int64_t nValue, CWalletTx& wtxNe
15151525

15161526

15171527

1518-
string CWallet::SendMoneyToDestination(const CTxDestination& address, int64_t nValue, CWalletTx& wtxNew)
1519-
{
1520-
// Check amount
1521-
if (nValue <= 0)
1522-
return _("Invalid amount");
1523-
if (nValue > GetBalance())
1524-
return _("Insufficient funds");
1525-
1526-
// Parse Bitcoin address
1527-
CScript scriptPubKey;
1528-
scriptPubKey.SetDestination(address);
1529-
1530-
return SendMoney(scriptPubKey, nValue, wtxNew);
1531-
}
1532-
15331528
int64_t CWallet::GetMinimumFee(unsigned int nTxBytes, unsigned int nConfirmTarget, const CTxMemPool& pool)
15341529
{
15351530
// payTxFee is user-set "I want to pay this much"

src/wallet.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,8 +265,7 @@ class CWallet : public CCryptoKeyStore, public CWalletInterface
265265
bool CreateTransaction(CScript scriptPubKey, int64_t nValue,
266266
CWalletTx& wtxNew, CReserveKey& reservekey, int64_t& nFeeRet, std::string& strFailReason, const CCoinControl *coinControl = NULL);
267267
bool CommitTransaction(CWalletTx& wtxNew, CReserveKey& reservekey);
268-
std::string SendMoney(CScript scriptPubKey, int64_t nValue, CWalletTx& wtxNew);
269-
std::string SendMoneyToDestination(const CTxDestination &address, int64_t nValue, CWalletTx& wtxNew);
268+
std::string SendMoney(const CTxDestination &address, int64_t nValue, CWalletTx& wtxNew);
270269

271270
static CFeeRate minTxFee;
272271
static int64_t GetMinimumFee(unsigned int nTxBytes, unsigned int nConfirmTarget, const CTxMemPool& pool);

0 commit comments

Comments
 (0)