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).
This commit is contained in:
parent
4ed2315e86
commit
e832ab7754
@ -346,7 +346,7 @@ Value sendtoaddress(const Array& params, bool fHelp)
|
|||||||
|
|
||||||
EnsureWalletIsUnlocked();
|
EnsureWalletIsUnlocked();
|
||||||
|
|
||||||
string strError = pwalletMain->SendMoneyToDestination(address.Get(), nAmount, wtx);
|
string strError = pwalletMain->SendMoney(address.Get(), nAmount, wtx);
|
||||||
if (strError != "")
|
if (strError != "")
|
||||||
throw JSONRPCError(RPC_WALLET_ERROR, strError);
|
throw JSONRPCError(RPC_WALLET_ERROR, strError);
|
||||||
|
|
||||||
@ -786,7 +786,7 @@ Value sendfrom(const Array& params, bool fHelp)
|
|||||||
throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, "Account has insufficient funds");
|
throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, "Account has insufficient funds");
|
||||||
|
|
||||||
// Send
|
// Send
|
||||||
string strError = pwalletMain->SendMoneyToDestination(address.Get(), nAmount, wtx);
|
string strError = pwalletMain->SendMoney(address.Get(), nAmount, wtx);
|
||||||
if (strError != "")
|
if (strError != "")
|
||||||
throw JSONRPCError(RPC_WALLET_ERROR, strError);
|
throw JSONRPCError(RPC_WALLET_ERROR, strError);
|
||||||
|
|
||||||
|
@ -1487,35 +1487,7 @@ bool CWallet::CommitTransaction(CWalletTx& wtxNew, CReserveKey& reservekey)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
string CWallet::SendMoney(CScript scriptPubKey, int64_t nValue, CWalletTx& wtxNew)
|
string CWallet::SendMoney(const CTxDestination &address, int64_t nValue, CWalletTx& wtxNew)
|
||||||
{
|
|
||||||
CReserveKey reservekey(this);
|
|
||||||
int64_t nFeeRequired;
|
|
||||||
|
|
||||||
if (IsLocked())
|
|
||||||
{
|
|
||||||
string strError = _("Error: Wallet locked, unable to create transaction!");
|
|
||||||
LogPrintf("SendMoney() : %s", strError);
|
|
||||||
return strError;
|
|
||||||
}
|
|
||||||
string strError;
|
|
||||||
if (!CreateTransaction(scriptPubKey, nValue, wtxNew, reservekey, nFeeRequired, strError))
|
|
||||||
{
|
|
||||||
if (nValue + nFeeRequired > GetBalance())
|
|
||||||
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));
|
|
||||||
LogPrintf("SendMoney() : %s\n", strError);
|
|
||||||
return strError;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!CommitTransaction(wtxNew, reservekey))
|
|
||||||
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.");
|
|
||||||
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
string CWallet::SendMoneyToDestination(const CTxDestination& address, int64_t nValue, CWalletTx& wtxNew)
|
|
||||||
{
|
{
|
||||||
// Check amount
|
// Check amount
|
||||||
if (nValue <= 0)
|
if (nValue <= 0)
|
||||||
@ -1523,12 +1495,35 @@ string CWallet::SendMoneyToDestination(const CTxDestination& address, int64_t nV
|
|||||||
if (nValue > GetBalance())
|
if (nValue > GetBalance())
|
||||||
return _("Insufficient funds");
|
return _("Insufficient funds");
|
||||||
|
|
||||||
|
string strError;
|
||||||
|
if (IsLocked())
|
||||||
|
{
|
||||||
|
strError = _("Error: Wallet locked, unable to create transaction!");
|
||||||
|
LogPrintf("SendMoney() : %s", strError);
|
||||||
|
return strError;
|
||||||
|
}
|
||||||
|
|
||||||
// Parse Bitcoin address
|
// Parse Bitcoin address
|
||||||
CScript scriptPubKey;
|
CScript scriptPubKey;
|
||||||
scriptPubKey.SetDestination(address);
|
scriptPubKey.SetDestination(address);
|
||||||
|
|
||||||
return SendMoney(scriptPubKey, nValue, wtxNew);
|
// Create and send the transaction
|
||||||
|
CReserveKey reservekey(this);
|
||||||
|
int64_t nFeeRequired;
|
||||||
|
if (!CreateTransaction(scriptPubKey, nValue, wtxNew, reservekey, nFeeRequired, strError))
|
||||||
|
{
|
||||||
|
if (nValue + nFeeRequired > GetBalance())
|
||||||
|
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));
|
||||||
|
LogPrintf("SendMoney() : %s\n", strError);
|
||||||
|
return strError;
|
||||||
}
|
}
|
||||||
|
if (!CommitTransaction(wtxNew, reservekey))
|
||||||
|
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.");
|
||||||
|
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int64_t CWallet::GetMinimumFee(unsigned int nTxBytes, unsigned int nConfirmTarget, const CTxMemPool& pool)
|
int64_t CWallet::GetMinimumFee(unsigned int nTxBytes, unsigned int nConfirmTarget, const CTxMemPool& pool)
|
||||||
{
|
{
|
||||||
|
@ -265,8 +265,7 @@ public:
|
|||||||
bool CreateTransaction(CScript scriptPubKey, int64_t nValue,
|
bool CreateTransaction(CScript scriptPubKey, int64_t nValue,
|
||||||
CWalletTx& wtxNew, CReserveKey& reservekey, int64_t& nFeeRet, std::string& strFailReason, const CCoinControl *coinControl = NULL);
|
CWalletTx& wtxNew, CReserveKey& reservekey, int64_t& nFeeRet, std::string& strFailReason, const CCoinControl *coinControl = NULL);
|
||||||
bool CommitTransaction(CWalletTx& wtxNew, CReserveKey& reservekey);
|
bool CommitTransaction(CWalletTx& wtxNew, CReserveKey& reservekey);
|
||||||
std::string SendMoney(CScript scriptPubKey, int64_t nValue, CWalletTx& wtxNew);
|
std::string SendMoney(const CTxDestination &address, int64_t nValue, CWalletTx& wtxNew);
|
||||||
std::string SendMoneyToDestination(const CTxDestination &address, int64_t nValue, CWalletTx& wtxNew);
|
|
||||||
|
|
||||||
static CFeeRate minTxFee;
|
static CFeeRate minTxFee;
|
||||||
static int64_t GetMinimumFee(unsigned int nTxBytes, unsigned int nConfirmTarget, const CTxMemPool& pool);
|
static int64_t GetMinimumFee(unsigned int nTxBytes, unsigned int nConfirmTarget, const CTxMemPool& pool);
|
||||||
|
Loading…
Reference in New Issue
Block a user