Changeset View
Changeset View
Standalone View
Standalone View
src/qt/walletmodeltransaction.cpp
Show All 28 Lines | |||||
unsigned int WalletModelTransaction::getTransactionSize() { | unsigned int WalletModelTransaction::getTransactionSize() { | ||||
return (!walletTransaction ? 0 : ::GetTransactionSize(*walletTransaction)); | return (!walletTransaction ? 0 : ::GetTransactionSize(*walletTransaction)); | ||||
} | } | ||||
CAmount WalletModelTransaction::getTransactionFee() { | CAmount WalletModelTransaction::getTransactionFee() { | ||||
return fee; | return fee; | ||||
} | } | ||||
void WalletModelTransaction::setTransactionFee(const CAmount &newFee) { | void WalletModelTransaction::setTransactionFee(const CAmount newFee) { | ||||
fee = newFee; | fee = newFee; | ||||
} | } | ||||
void WalletModelTransaction::reassignAmounts(int nChangePosRet) { | void WalletModelTransaction::reassignAmounts(int nChangePosRet) { | ||||
int i = 0; | int i = 0; | ||||
for (SendCoinsRecipient &rcp : recipients) { | for (SendCoinsRecipient &rcp : recipients) { | ||||
if (rcp.paymentRequest.IsInitialized()) { | if (rcp.paymentRequest.IsInitialized()) { | ||||
Amount subtotal = 0; | Amount subtotal(0); | ||||
const payments::PaymentDetails &details = | const payments::PaymentDetails &details = | ||||
rcp.paymentRequest.getDetails(); | rcp.paymentRequest.getDetails(); | ||||
for (int j = 0; j < details.outputs_size(); j++) { | for (int j = 0; j < details.outputs_size(); j++) { | ||||
const payments::Output &out = details.outputs(j); | const payments::Output &out = details.outputs(j); | ||||
if (out.amount() <= 0) continue; | if (out.amount() <= 0) continue; | ||||
if (i == nChangePosRet) i++; | if (i == nChangePosRet) i++; | ||||
subtotal += walletTransaction->tx->vout[i].nValue; | subtotal += walletTransaction->tx->vout[i].nValue; | ||||
i++; | i++; | ||||
} | } | ||||
rcp.amount = subtotal.GetSatoshis(); | rcp.amount = subtotal.GetSatoshis(); | ||||
} else { | } else { | ||||
// normal recipient (no payment request) | // normal recipient (no payment request) | ||||
if (i == nChangePosRet) i++; | if (i == nChangePosRet) i++; | ||||
rcp.amount = walletTransaction->tx->vout[i].nValue.GetSatoshis(); | rcp.amount = walletTransaction->tx->vout[i].nValue.GetSatoshis(); | ||||
i++; | i++; | ||||
} | } | ||||
} | } | ||||
} | } | ||||
CAmount WalletModelTransaction::getTotalTransactionAmount() { | CAmount WalletModelTransaction::getTotalTransactionAmount() { | ||||
CAmount totalTransactionAmount = 0; | Amount totalTransactionAmount(0); | ||||
for (const SendCoinsRecipient &rcp : recipients) { | for (const SendCoinsRecipient &rcp : recipients) { | ||||
totalTransactionAmount += rcp.amount; | totalTransactionAmount += rcp.amount; | ||||
} | } | ||||
return totalTransactionAmount; | return totalTransactionAmount.GetSatoshis(); | ||||
} | } | ||||
void WalletModelTransaction::newPossibleKeyChange(CWallet *wallet) { | void WalletModelTransaction::newPossibleKeyChange(CWallet *wallet) { | ||||
keyChange = new CReserveKey(wallet); | keyChange = new CReserveKey(wallet); | ||||
} | } | ||||
CReserveKey *WalletModelTransaction::getPossibleKeyChange() { | CReserveKey *WalletModelTransaction::getPossibleKeyChange() { | ||||
return keyChange; | return keyChange; | ||||
} | } |