@@ -1627,15 +1627,14 @@ bool CWallet::ImportScriptPubKeys(const std::string& label, const std::set<CScri
1627
1627
return true ;
1628
1628
}
1629
1629
1630
- // Returns pair of vsize and weight
1631
- std::pair<int64_t , int64_t > CalculateMaximumSignedTxSize (const CTransaction &tx, const CWallet *wallet, bool use_max_sig)
1630
+ TxSize CalculateMaximumSignedTxSize (const CTransaction &tx, const CWallet *wallet, bool use_max_sig)
1632
1631
{
1633
1632
std::vector<CTxOut> txouts;
1634
1633
for (const CTxIn& input : tx.vin ) {
1635
1634
const auto mi = wallet->mapWallet .find (input.prevout .hash );
1636
1635
// Can not estimate size without knowing the input details
1637
1636
if (mi == wallet->mapWallet .end ()) {
1638
- return std::make_pair ( -1 , -1 ) ;
1637
+ return TxSize{ -1 , -1 } ;
1639
1638
}
1640
1639
assert (input.prevout .n < mi->second .tx ->vout .size ());
1641
1640
txouts.emplace_back (mi->second .tx ->vout [input.prevout .n ]);
@@ -1644,16 +1643,16 @@ std::pair<int64_t, int64_t> CalculateMaximumSignedTxSize(const CTransaction &tx,
1644
1643
}
1645
1644
1646
1645
// txouts needs to be in the order of tx.vin
1647
- std::pair< int64_t , int64_t > CalculateMaximumSignedTxSize (const CTransaction &tx, const CWallet *wallet, const std::vector<CTxOut>& txouts, bool use_max_sig)
1646
+ TxSize CalculateMaximumSignedTxSize (const CTransaction &tx, const CWallet *wallet, const std::vector<CTxOut>& txouts, bool use_max_sig)
1648
1647
{
1649
1648
CMutableTransaction txNew (tx);
1650
1649
if (!wallet->DummySignTx (txNew, txouts, use_max_sig)) {
1651
- return std::make_pair ( -1 , -1 ) ;
1650
+ return TxSize{ -1 , -1 } ;
1652
1651
}
1653
1652
CTransaction ctx (txNew);
1654
1653
int64_t vsize = GetVirtualTransactionSize (ctx);
1655
1654
int64_t weight = GetTransactionWeight (ctx);
1656
- return std::make_pair ( vsize, weight) ;
1655
+ return TxSize{ vsize, weight} ;
1657
1656
}
1658
1657
1659
1658
int CalculateMaximumSignedInputSize (const CTxOut& txout, const CWallet* wallet, bool use_max_sig)
@@ -2820,7 +2819,7 @@ bool CWallet::CreateTransactionInternal(
2820
2819
2821
2820
CMutableTransaction txNew;
2822
2821
FeeCalculation feeCalc;
2823
- std::pair< int64_t , int64_t > tx_sizes;
2822
+ TxSize tx_sizes;
2824
2823
int nBytes;
2825
2824
{
2826
2825
std::set<CInputCoin> setCoins;
@@ -2967,7 +2966,7 @@ bool CWallet::CreateTransactionInternal(
2967
2966
2968
2967
// Calculate the transaction fee
2969
2968
tx_sizes = CalculateMaximumSignedTxSize (CTransaction (txNew), this , coin_control.fAllowWatchOnly );
2970
- nBytes = tx_sizes.first ;
2969
+ nBytes = tx_sizes.vsize ;
2971
2970
if (nBytes < 0 ) {
2972
2971
error = _ (" Signing transaction failed" );
2973
2972
return false ;
@@ -2992,7 +2991,7 @@ bool CWallet::CreateTransactionInternal(
2992
2991
2993
2992
// Because we have dropped this change, the tx size and required fee will be different, so let's recalculate those
2994
2993
tx_sizes = CalculateMaximumSignedTxSize (CTransaction (txNew), this , coin_control.fAllowWatchOnly );
2995
- nBytes = tx_sizes.first ;
2994
+ nBytes = tx_sizes.vsize ;
2996
2995
fee_needed = coin_selection_params.m_effective_feerate .GetFee (nBytes);
2997
2996
}
2998
2997
@@ -3072,7 +3071,7 @@ bool CWallet::CreateTransactionInternal(
3072
3071
3073
3072
// Limit size
3074
3073
if ((sign && GetTransactionWeight (*tx) > MAX_STANDARD_TX_WEIGHT) ||
3075
- (!sign && tx_sizes.second > MAX_STANDARD_TX_WEIGHT))
3074
+ (!sign && tx_sizes.weight > MAX_STANDARD_TX_WEIGHT))
3076
3075
{
3077
3076
error = _ (" Transaction too large" );
3078
3077
return false ;
0 commit comments