diff options
author | ismaelsadeeq <ask4ismailsadiq@gmail.com> | 2024-03-21 17:05:51 +0100 |
---|---|---|
committer | ismaelsadeeq <ask4ismailsadiq@gmail.com> | 2024-06-27 12:37:33 +0100 |
commit | b6fc5043c16c2467a2a6768a6ca9b18035fc400f (patch) | |
tree | ce3fe8d8de00011782a70dfd408370a3419af3fa /src | |
parent | baab0d2d43049a71dc90176bc4d72062f7b2ce19 (diff) |
[wallet]: update the data type of `change_output_size`, `change_spend_size` and `tx_noinputs_size` to `int`
- This change ensures consistency in transaction size and weight calculation
within the wallet and prevents conversion overflow when calculating
`max_selection_weight`.
Diffstat (limited to 'src')
-rw-r--r-- | src/wallet/coinselection.h | 10 | ||||
-rw-r--r-- | src/wallet/spend.cpp | 2 |
2 files changed, 6 insertions, 6 deletions
diff --git a/src/wallet/coinselection.h b/src/wallet/coinselection.h index 6b0d1ab2a4..1f234427d2 100644 --- a/src/wallet/coinselection.h +++ b/src/wallet/coinselection.h @@ -139,9 +139,9 @@ struct CoinSelectionParams { /** Randomness to use in the context of coin selection. */ FastRandomContext& rng_fast; /** Size of a change output in bytes, determined by the output type. */ - size_t change_output_size = 0; + int change_output_size = 0; /** Size of the input to spend a change output in virtual bytes. */ - size_t change_spend_size = 0; + int change_spend_size = 0; /** Mininmum change to target in Knapsack solver and CoinGrinder: * select coins to cover the payment and at least this value of change. */ CAmount m_min_change_target{0}; @@ -162,7 +162,7 @@ struct CoinSelectionParams { CFeeRate m_discard_feerate; /** Size of the transaction before coin selection, consisting of the header and recipient * output(s), excluding the inputs and change output(s). */ - size_t tx_noinputs_size = 0; + int tx_noinputs_size = 0; /** Indicate that we are subtracting the fee from outputs */ bool m_subtract_fee_outputs = false; /** When true, always spend all (up to OUTPUT_GROUP_MAX_ENTRIES) or none of the outputs @@ -175,9 +175,9 @@ struct CoinSelectionParams { */ bool m_include_unsafe_inputs = false; - CoinSelectionParams(FastRandomContext& rng_fast, size_t change_output_size, size_t change_spend_size, + CoinSelectionParams(FastRandomContext& rng_fast, int change_output_size, int change_spend_size, CAmount min_change_target, CFeeRate effective_feerate, - CFeeRate long_term_feerate, CFeeRate discard_feerate, size_t tx_noinputs_size, bool avoid_partial) + CFeeRate long_term_feerate, CFeeRate discard_feerate, int tx_noinputs_size, bool avoid_partial) : rng_fast{rng_fast}, change_output_size(change_output_size), change_spend_size(change_spend_size), diff --git a/src/wallet/spend.cpp b/src/wallet/spend.cpp index 4759f1eb95..e0546c6210 100644 --- a/src/wallet/spend.cpp +++ b/src/wallet/spend.cpp @@ -1059,7 +1059,7 @@ static util::Result<CreatedTransactionResult> CreateTransactionInternal( if (change_spend_size == -1) { coin_selection_params.change_spend_size = DUMMY_NESTED_P2WPKH_INPUT_SIZE; } else { - coin_selection_params.change_spend_size = (size_t)change_spend_size; + coin_selection_params.change_spend_size = change_spend_size; } // Set discard feerate |