mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-14 12:43:40 +02:00
Merge 7aa41fc581 into merged_master (Bitcoin PR bitcoin/bitcoin#22042)
This commit is contained in:
commit
81eb03b40c
3 changed files with 18 additions and 13 deletions
|
|
@ -207,7 +207,7 @@ Result CreateRateBumpTransaction(CWallet& wallet, const uint256& txid, const CCo
|
|||
if (coin_control.m_feerate) {
|
||||
// The user provided a feeRate argument.
|
||||
// We calculate this here to avoid compiler warning on the cs_wallet lock
|
||||
const int64_t maxTxSize = CalculateMaximumSignedTxSize(*wtx.tx, &wallet).first;
|
||||
const int64_t maxTxSize{CalculateMaximumSignedTxSize(*wtx.tx, &wallet).vsize};
|
||||
Result res = CheckFeeRate(wallet, wtx, *new_coin_control.m_feerate, maxTxSize, errors);
|
||||
if (res != Result::OK) {
|
||||
return res;
|
||||
|
|
|
|||
|
|
@ -1675,7 +1675,7 @@ bool CWallet::ImportScriptPubKeys(const std::string& label, const std::set<CScri
|
|||
}
|
||||
|
||||
// Returns pair of vsize and weight
|
||||
std::pair<int64_t, int64_t> CalculateMaximumSignedTxSize(const CTransaction &tx, const CWallet *wallet, const CCoinControl* coin_control)
|
||||
TxSize CalculateMaximumSignedTxSize(const CTransaction &tx, const CWallet *wallet, const CCoinControl* coin_control)
|
||||
{
|
||||
std::vector<CTxOut> txouts;
|
||||
// Look up the inputs. The inputs are either in the wallet, or in coin_control.
|
||||
|
|
@ -1687,27 +1687,27 @@ std::pair<int64_t, int64_t> CalculateMaximumSignedTxSize(const CTransaction &tx,
|
|||
} else if (coin_control) {
|
||||
CTxOut txout;
|
||||
if (!coin_control->GetExternalOutput(input.prevout, txout)) {
|
||||
return std::make_pair(-1, -1);
|
||||
return TxSize{-1, -1};
|
||||
}
|
||||
txouts.emplace_back(txout);
|
||||
} else {
|
||||
return std::make_pair(-1, -1);
|
||||
return TxSize{-1, -1};
|
||||
}
|
||||
}
|
||||
return CalculateMaximumSignedTxSize(tx, wallet, txouts, coin_control);
|
||||
}
|
||||
|
||||
// txouts needs to be in the order of tx.vin
|
||||
std::pair<int64_t, int64_t> CalculateMaximumSignedTxSize(const CTransaction &tx, const CWallet *wallet, const std::vector<CTxOut>& txouts, const CCoinControl* coin_control)
|
||||
TxSize CalculateMaximumSignedTxSize(const CTransaction &tx, const CWallet *wallet, const std::vector<CTxOut>& txouts, const CCoinControl* coin_control)
|
||||
{
|
||||
CMutableTransaction txNew(tx);
|
||||
if (!wallet->DummySignTx(txNew, txouts, coin_control)) {
|
||||
return std::make_pair(-1, -1);
|
||||
return TxSize{-1, -1};
|
||||
}
|
||||
CTransaction ctx(txNew);
|
||||
int64_t vsize = GetVirtualTransactionSize(ctx);
|
||||
int64_t weight = GetTransactionWeight(ctx);
|
||||
return std::make_pair(vsize, weight);
|
||||
return TxSize{vsize, weight};
|
||||
}
|
||||
|
||||
int CalculateMaximumSignedInputSize(const CTxOut& txout, const SigningProvider* provider, bool use_max_sig) {
|
||||
|
|
@ -3311,7 +3311,7 @@ bool CWallet::CreateTransactionInternal(
|
|||
|
||||
CMutableTransaction txNew;
|
||||
FeeCalculation feeCalc;
|
||||
std::pair<int64_t, int64_t> tx_sizes;
|
||||
TxSize tx_sizes;
|
||||
int nBytes;
|
||||
{
|
||||
std::set<CInputCoin> setCoins;
|
||||
|
|
@ -3736,7 +3736,7 @@ bool CWallet::CreateTransactionInternal(
|
|||
// end ELEMENTS
|
||||
|
||||
// Calculate the transaction fee
|
||||
nBytes = tx_sizes.first;
|
||||
nBytes = tx_sizes.vsize;
|
||||
if (nBytes < 0) {
|
||||
error = _("Signing transaction failed");
|
||||
return false;
|
||||
|
|
@ -3780,7 +3780,7 @@ bool CWallet::CreateTransactionInternal(
|
|||
|
||||
// Because we have dropped this change, the tx size and required fee will be different, so let's recalculate those
|
||||
tx_sizes = CalculateMaximumSignedTxSize(CTransaction(tx_blinded), this, &coin_control);
|
||||
nBytes = tx_sizes.first;
|
||||
nBytes = tx_sizes.vsize;
|
||||
fee_needed = coin_selection_params.m_effective_feerate.GetFee(nBytes);
|
||||
}
|
||||
|
||||
|
|
@ -3950,7 +3950,7 @@ bool CWallet::CreateTransactionInternal(
|
|||
|
||||
// Limit size
|
||||
if ((sign && GetTransactionWeight(*tx) > MAX_STANDARD_TX_WEIGHT) ||
|
||||
(!sign && tx_sizes.second > MAX_STANDARD_TX_WEIGHT))
|
||||
(!sign && tx_sizes.weight > MAX_STANDARD_TX_WEIGHT))
|
||||
{
|
||||
error = _("Transaction too large");
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -1501,12 +1501,17 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
struct TxSize {
|
||||
int64_t vsize{-1};
|
||||
int64_t weight{-1};
|
||||
};
|
||||
|
||||
/** Calculate the size of the transaction assuming all signatures are max size
|
||||
* Use DummySignatureCreator, which inserts 71 byte signatures everywhere.
|
||||
* NOTE: this requires that all inputs must be in mapWallet (eg the tx should
|
||||
* be IsAllFromMe). */
|
||||
std::pair<int64_t, int64_t> CalculateMaximumSignedTxSize(const CTransaction &tx, const CWallet *wallet, const CCoinControl* coin_control = nullptr) EXCLUSIVE_LOCKS_REQUIRED(wallet->cs_wallet);
|
||||
std::pair<int64_t, int64_t> CalculateMaximumSignedTxSize(const CTransaction &tx, const CWallet *wallet, const std::vector<CTxOut>& txouts, const CCoinControl* coin_control = nullptr);
|
||||
TxSize CalculateMaximumSignedTxSize(const CTransaction &tx, const CWallet *wallet, const CCoinControl* coin_control = nullptr) EXCLUSIVE_LOCKS_REQUIRED(wallet->cs_wallet);
|
||||
TxSize CalculateMaximumSignedTxSize(const CTransaction &tx, const CWallet *wallet, const std::vector<CTxOut>& txouts, const CCoinControl* coin_control = nullptr);
|
||||
|
||||
//! Add wallet name to persistent configuration so it will be loaded on startup.
|
||||
bool AddWalletSetting(interfaces::Chain& chain, const std::string& wallet_name);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue