Merge pull request #2958 from laanwj/2013_08_txfee2
[Qt] Display txfee in first sendCoinsDialog message box
This commit is contained in:
@@ -5,7 +5,6 @@
|
||||
#include "transactiontablemodel.h"
|
||||
|
||||
#include "ui_interface.h"
|
||||
#include "wallet.h"
|
||||
#include "walletdb.h" // for BackupWallet
|
||||
#include "base58.h"
|
||||
|
||||
@@ -125,11 +124,11 @@ bool WalletModel::validateAddress(const QString &address)
|
||||
return addressParsed.IsValid();
|
||||
}
|
||||
|
||||
WalletModel::SendCoinsReturn WalletModel::sendCoins(const QList<SendCoinsRecipient> &recipients)
|
||||
WalletModel::SendCoinsReturn WalletModel::prepareTransaction(WalletModelTransaction &transaction)
|
||||
{
|
||||
qint64 total = 0;
|
||||
QList<SendCoinsRecipient> recipients = transaction.getRecipients();
|
||||
std::vector<std::pair<CScript, int64> > vecSend;
|
||||
QByteArray transaction;
|
||||
|
||||
if(recipients.empty())
|
||||
{
|
||||
@@ -193,58 +192,70 @@ WalletModel::SendCoinsReturn WalletModel::sendCoins(const QList<SendCoinsRecipie
|
||||
|
||||
if((total + nTransactionFee) > getBalance())
|
||||
{
|
||||
return SendCoinsReturn(AmountWithFeeExceedsBalance, nTransactionFee);
|
||||
transaction.setTransactionFee(nTransactionFee);
|
||||
return SendCoinsReturn(AmountWithFeeExceedsBalance);
|
||||
}
|
||||
|
||||
{
|
||||
LOCK2(cs_main, wallet->cs_wallet);
|
||||
|
||||
CReserveKey keyChange(wallet);
|
||||
transaction.newPossibleKeyChange(wallet);
|
||||
int64 nFeeRequired = 0;
|
||||
std::string strFailReason;
|
||||
CWalletTx wtx;
|
||||
bool fCreated = wallet->CreateTransaction(vecSend, wtx, keyChange, nFeeRequired, strFailReason);
|
||||
|
||||
CWalletTx *newTx = transaction.getTransaction();
|
||||
CReserveKey *keyChange = transaction.getPossibleKeyChange();
|
||||
bool fCreated = wallet->CreateTransaction(vecSend, *newTx, *keyChange, nFeeRequired, strFailReason);
|
||||
transaction.setTransactionFee(nFeeRequired);
|
||||
|
||||
if(!fCreated)
|
||||
{
|
||||
if((total + nFeeRequired) > wallet->GetBalance())
|
||||
{
|
||||
return SendCoinsReturn(AmountWithFeeExceedsBalance, nFeeRequired);
|
||||
return SendCoinsReturn(AmountWithFeeExceedsBalance);
|
||||
}
|
||||
emit message(tr("Send Coins"), QString::fromStdString(strFailReason),
|
||||
CClientUIInterface::MSG_ERROR);
|
||||
return TransactionCreationFailed;
|
||||
}
|
||||
}
|
||||
|
||||
return SendCoinsReturn(OK);
|
||||
}
|
||||
|
||||
WalletModel::SendCoinsReturn WalletModel::sendCoins(WalletModelTransaction &transaction)
|
||||
{
|
||||
QByteArray transaction_array; /* store serialized transaction */
|
||||
|
||||
{
|
||||
LOCK2(cs_main, wallet->cs_wallet);
|
||||
CWalletTx *newTx = transaction.getTransaction();
|
||||
|
||||
// Store PaymentRequests in wtx.vOrderForm in wallet.
|
||||
foreach(const SendCoinsRecipient &rcp, recipients)
|
||||
foreach(const SendCoinsRecipient &rcp, transaction.getRecipients())
|
||||
{
|
||||
if (rcp.paymentRequest.IsInitialized())
|
||||
{
|
||||
std::string key("PaymentRequest");
|
||||
std::string value;
|
||||
rcp.paymentRequest.SerializeToString(&value);
|
||||
wtx.vOrderForm.push_back(make_pair(key, value));
|
||||
newTx->vOrderForm.push_back(make_pair(key, value));
|
||||
}
|
||||
}
|
||||
|
||||
if(!uiInterface.ThreadSafeAskFee(nFeeRequired))
|
||||
{
|
||||
return Aborted;
|
||||
}
|
||||
if(!wallet->CommitTransaction(wtx, keyChange))
|
||||
{
|
||||
|
||||
CReserveKey *keyChange = transaction.getPossibleKeyChange();
|
||||
if(!wallet->CommitTransaction(*newTx, *keyChange))
|
||||
return TransactionCommitFailed;
|
||||
}
|
||||
|
||||
CTransaction* t = (CTransaction*)&wtx;
|
||||
CTransaction* t = (CTransaction*)newTx;
|
||||
CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION);
|
||||
ssTx << *t;
|
||||
transaction.append(&(ssTx[0]), ssTx.size());
|
||||
transaction_array.append(&(ssTx[0]), ssTx.size());
|
||||
}
|
||||
|
||||
// Add addresses / update labels that we've sent to to the address book,
|
||||
// and emit coinsSent signal
|
||||
foreach(const SendCoinsRecipient &rcp, recipients)
|
||||
// and emit coinsSent signal for each recipient
|
||||
foreach(const SendCoinsRecipient &rcp, transaction.getRecipients())
|
||||
{
|
||||
std::string strAddress = rcp.address.toStdString();
|
||||
CTxDestination dest = CBitcoinAddress(strAddress).Get();
|
||||
@@ -264,10 +275,10 @@ WalletModel::SendCoinsReturn WalletModel::sendCoins(const QList<SendCoinsRecipie
|
||||
wallet->SetAddressBook(dest, strLabel, ""); // "" means don't change purpose
|
||||
}
|
||||
}
|
||||
emit coinsSent(wallet, rcp, transaction);
|
||||
emit coinsSent(wallet, rcp, transaction_array);
|
||||
}
|
||||
|
||||
return SendCoinsReturn(OK, 0);
|
||||
return SendCoinsReturn(OK);
|
||||
}
|
||||
|
||||
OptionsModel *WalletModel::getOptionsModel()
|
||||
|
||||
Reference in New Issue
Block a user