BIP144: Serialization, hashes, relay (sender side)
Contains refactorings by Eric Lombrozo. Contains fixup by Nicolas Dorier. Contains cleanup of CInv::GetCommand by Alex Morcos
This commit is contained in:
@@ -485,6 +485,7 @@ void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog)
|
||||
unsigned int nQuantity = 0;
|
||||
int nQuantityUncompressed = 0;
|
||||
bool fAllowFree = false;
|
||||
bool fWitness = false;
|
||||
|
||||
std::vector<COutPoint> vCoinControl;
|
||||
std::vector<COutput> vOutputs;
|
||||
@@ -513,7 +514,14 @@ void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog)
|
||||
|
||||
// Bytes
|
||||
CTxDestination address;
|
||||
if(ExtractDestination(out.tx->vout[out.i].scriptPubKey, address))
|
||||
int witnessversion = 0;
|
||||
std::vector<unsigned char> witnessprogram;
|
||||
if (out.tx->vout[out.i].scriptPubKey.IsWitnessProgram(witnessversion, witnessprogram))
|
||||
{
|
||||
nBytesInputs += (32 + 4 + 1 + (107 / WITNESS_SCALE_FACTOR) + 4);
|
||||
fWitness = true;
|
||||
}
|
||||
else if(ExtractDestination(out.tx->vout[out.i].scriptPubKey, address))
|
||||
{
|
||||
CPubKey pubkey;
|
||||
CKeyID *keyid = boost::get<CKeyID>(&address);
|
||||
@@ -534,6 +542,14 @@ void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog)
|
||||
{
|
||||
// Bytes
|
||||
nBytes = nBytesInputs + ((CoinControlDialog::payAmounts.size() > 0 ? CoinControlDialog::payAmounts.size() + 1 : 2) * 34) + 10; // always assume +1 output for change here
|
||||
if (fWitness)
|
||||
{
|
||||
// there is some fudging in these numbers related to the actual virtual transaction size calculation that will keep this estimate from being exact.
|
||||
// usually, the result will be an overestimate within a couple of satoshis so that the confirmation dialog ends up displaying a slightly smaller fee.
|
||||
// also, the witness stack size value value is a variable sized integer. usually, the number of stack items will be well under the single byte var int limit.
|
||||
nBytes += 2; // account for the serialized marker and flag bytes
|
||||
nBytes += nQuantity; // account for the witness byte that holds the number of stack items for each input.
|
||||
}
|
||||
|
||||
// Priority
|
||||
double mempoolEstimatePriority = mempool.estimateSmartPriority(nTxConfirmTarget);
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#include "walletmodeltransaction.h"
|
||||
|
||||
#include "policy/policy.h"
|
||||
#include "wallet/wallet.h"
|
||||
|
||||
WalletModelTransaction::WalletModelTransaction(const QList<SendCoinsRecipient> &recipients) :
|
||||
@@ -33,7 +34,7 @@ CWalletTx *WalletModelTransaction::getTransaction()
|
||||
|
||||
unsigned int WalletModelTransaction::getTransactionSize()
|
||||
{
|
||||
return (!walletTransaction ? 0 : (::GetSerializeSize(*(CTransaction*)walletTransaction, SER_NETWORK, PROTOCOL_VERSION)));
|
||||
return (!walletTransaction ? 0 : ::GetVirtualTransactionSize(*walletTransaction));
|
||||
}
|
||||
|
||||
CAmount WalletModelTransaction::getTransactionFee()
|
||||
|
||||
Reference in New Issue
Block a user