@@ -1594,14 +1594,15 @@ bool CWallet::ImportScriptPubKeys(const std::string& label, const std::set<CScri
1594
1594
return true ;
1595
1595
}
1596
1596
1597
- int64_t CalculateMaximumSignedTxSize (const CTransaction &tx, const CWallet *wallet, bool use_max_sig)
1597
+ // Returns pair of vsize and weight
1598
+ std::pair<int64_t , int64_t > CalculateMaximumSignedTxSize (const CTransaction &tx, const CWallet *wallet, bool use_max_sig)
1598
1599
{
1599
1600
std::vector<CTxOut> txouts;
1600
1601
for (const CTxIn& input : tx.vin ) {
1601
1602
const auto mi = wallet->mapWallet .find (input.prevout .hash );
1602
1603
// Can not estimate size without knowing the input details
1603
1604
if (mi == wallet->mapWallet .end ()) {
1604
- return - 1 ;
1605
+ return std::make_pair (- 1 , - 1 ) ;
1605
1606
}
1606
1607
assert (input.prevout .n < mi->second .tx ->vout .size ());
1607
1608
txouts.emplace_back (mi->second .tx ->vout [input.prevout .n ]);
@@ -1610,13 +1611,16 @@ int64_t CalculateMaximumSignedTxSize(const CTransaction &tx, const CWallet *wall
1610
1611
}
1611
1612
1612
1613
// txouts needs to be in the order of tx.vin
1613
- int64_t CalculateMaximumSignedTxSize (const CTransaction &tx, const CWallet *wallet, const std::vector<CTxOut>& txouts, bool use_max_sig)
1614
+ std::pair< int64_t , int64_t > CalculateMaximumSignedTxSize (const CTransaction &tx, const CWallet *wallet, const std::vector<CTxOut>& txouts, bool use_max_sig)
1614
1615
{
1615
1616
CMutableTransaction txNew (tx);
1616
1617
if (!wallet->DummySignTx (txNew, txouts, use_max_sig)) {
1617
- return - 1 ;
1618
+ return std::make_pair (- 1 , - 1 ) ;
1618
1619
}
1619
- return GetVirtualTransactionSize (CTransaction (txNew));
1620
+ CTransaction ctx (txNew);
1621
+ int64_t vsize = GetVirtualTransactionSize (ctx);
1622
+ int64_t weight = GetTransactionWeight (ctx);
1623
+ return std::make_pair (vsize, weight);
1620
1624
}
1621
1625
1622
1626
int CalculateMaximumSignedInputSize (const CTxOut& txout, const CWallet* wallet, bool use_max_sig)
@@ -2770,6 +2774,7 @@ bool CWallet::CreateTransactionInternal(
2770
2774
CMutableTransaction txNew;
2771
2775
FeeCalculation feeCalc;
2772
2776
CAmount nFeeNeeded;
2777
+ std::pair<int64_t , int64_t > tx_sizes;
2773
2778
int nBytes;
2774
2779
{
2775
2780
std::set<CInputCoin> setCoins;
@@ -2952,7 +2957,8 @@ bool CWallet::CreateTransactionInternal(
2952
2957
txNew.vin .push_back (CTxIn (coin.outpoint ,CScript ()));
2953
2958
}
2954
2959
2955
- nBytes = CalculateMaximumSignedTxSize (CTransaction (txNew), this , coin_control.fAllowWatchOnly );
2960
+ tx_sizes = CalculateMaximumSignedTxSize (CTransaction (txNew), this , coin_control.fAllowWatchOnly );
2961
+ nBytes = tx_sizes.first ;
2956
2962
if (nBytes < 0 ) {
2957
2963
error = _ (" Signing transaction failed" );
2958
2964
return false ;
0 commit comments