diff options
| author | Wladimir J. van der Laan <[email protected]> | 2014-07-07 10:17:41 +0200 |
|---|---|---|
| committer | Wladimir J. van der Laan <[email protected]> | 2014-07-07 10:22:58 +0200 |
| commit | bc06e8f402ec1859133a3d79c8946f2ce91e315c (patch) | |
| tree | 23e63158c769d3b7396c5c9df8a47abeac0e5065 /src/wallet.cpp | |
| parent | Merge pull request #4462 (diff) | |
| parent | Rename SendMoneyToDestination to SendMoney. (diff) | |
| download | discoin-bc06e8f402ec1859133a3d79c8946f2ce91e315c.tar.xz discoin-bc06e8f402ec1859133a3d79c8946f2ce91e315c.zip | |
Merge pull request #4463
e832ab7 Rename SendMoneyToDestination to SendMoney. (Daniel Kraft)
Diffstat (limited to 'src/wallet.cpp')
| -rw-r--r-- | src/wallet.cpp | 37 |
1 files changed, 16 insertions, 21 deletions
diff --git a/src/wallet.cpp b/src/wallet.cpp index 318a1388d..ed1b17860 100644 --- a/src/wallet.cpp +++ b/src/wallet.cpp @@ -1487,18 +1487,29 @@ 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; + // Check amount + if (nValue <= 0) + return _("Invalid amount"); + if (nValue > GetBalance()) + return _("Insufficient funds"); + string strError; if (IsLocked()) { - string strError = _("Error: Wallet locked, unable to create transaction!"); + strError = _("Error: Wallet locked, unable to create transaction!"); LogPrintf("SendMoney() : %s", strError); return strError; } - string strError; + + // Parse Bitcoin address + CScript scriptPubKey; + scriptPubKey.SetDestination(address); + + // Create and send the transaction + CReserveKey reservekey(this); + int64_t nFeeRequired; if (!CreateTransaction(scriptPubKey, nValue, wtxNew, reservekey, nFeeRequired, strError)) { if (nValue + nFeeRequired > GetBalance()) @@ -1506,7 +1517,6 @@ string CWallet::SendMoney(CScript scriptPubKey, int64_t nValue, CWalletTx& wtxNe 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."); @@ -1515,21 +1525,6 @@ string CWallet::SendMoney(CScript scriptPubKey, int64_t nValue, CWalletTx& wtxNe -string CWallet::SendMoneyToDestination(const CTxDestination& address, int64_t nValue, CWalletTx& wtxNew) -{ - // Check amount - if (nValue <= 0) - return _("Invalid amount"); - if (nValue > GetBalance()) - return _("Insufficient funds"); - - // Parse Bitcoin address - CScript scriptPubKey; - scriptPubKey.SetDestination(address); - - return SendMoney(scriptPubKey, nValue, wtxNew); -} - int64_t CWallet::GetMinimumFee(unsigned int nTxBytes, unsigned int nConfirmTarget, const CTxMemPool& pool) { // payTxFee is user-set "I want to pay this much" |