@@ -564,7 +564,15 @@ class COutput
564
564
{
565
565
public:
566
566
const CWalletTx *tx;
567
+
568
+ /* * Index in tx->vout. */
567
569
int i;
570
+
571
+ /* *
572
+ * Depth in block chain.
573
+ * If > 0: the tx is on chain and has this many confirmations.
574
+ * If = 0: the tx is waiting confirmation.
575
+ * If < 0: a conflicting tx is on chain and has this many confirmations. */
568
576
int nDepth;
569
577
570
578
/* * Pre-computed estimated size of this output as a fully-signed input in a transaction. Can be -1 if it could not be calculated */
@@ -604,17 +612,30 @@ class COutput
604
612
}
605
613
};
606
614
615
+ /* * Parameters for one iteration of Coin Selection. */
607
616
struct CoinSelectionParams
608
617
{
618
+ /* * Toggles use of Branch and Bound instead of Knapsack solver. */
609
619
bool use_bnb = true ;
620
+ /* * Size of a change output in bytes, determined by the output type. */
610
621
size_t change_output_size = 0 ;
622
+ /* * Size of the input to spend a change output in virtual bytes. */
611
623
size_t change_spend_size = 0 ;
624
+ /* * The targeted feerate of the transaction being built. */
612
625
CFeeRate m_effective_feerate;
626
+ /* * The feerate estimate used to estimate an upper bound on what should be sufficient to spend
627
+ * the change output sometime in the future. */
613
628
CFeeRate m_long_term_feerate;
629
+ /* * If the cost to spend a change output at the discard feerate exceeds its value, drop it to fees. */
614
630
CFeeRate m_discard_feerate;
631
+ /* * Size of the transaction before coin selection, consisting of the header and recipient
632
+ * output(s), excluding the inputs and change output(s). */
615
633
size_t tx_noinputs_size = 0 ;
616
634
/* * Indicate that we are subtracting the fee from outputs */
617
635
bool m_subtract_fee_outputs = false ;
636
+ /* * When true, always spend all (up to OUTPUT_GROUP_MAX_ENTRIES) or none of the outputs
637
+ * associated with the same address. This helps reduce privacy leaks resulting from address
638
+ * reuse. Dust outputs are not eligible to be added to output groups and thus not considered. */
618
639
bool m_avoid_partial_spends = false ;
619
640
620
641
CoinSelectionParams (bool use_bnb, size_t change_output_size, size_t change_spend_size, CFeeRate effective_feerate,
@@ -652,7 +673,10 @@ class CWallet final : public WalletStorage, public interfaces::Chain::Notificati
652
673
// ! the current wallet version: clients below this version are not able to load the wallet
653
674
int nWalletVersion GUARDED_BY (cs_wallet){FEATURE_BASE};
654
675
676
+ /* * The next scheduled rebroadcast of wallet transactions. */
655
677
int64_t nNextResend = 0 ;
678
+ /* * Whether this wallet will submit newly created transactions to the node's mempool and
679
+ * prompt rebroadcasts (see ResendWalletTransactions()). */
656
680
bool fBroadcastTransactions = false ;
657
681
// Local time that the tip block was received. Used to schedule wallet rebroadcasts.
658
682
std::atomic<int64_t > m_best_block_time {0 };
@@ -694,6 +718,7 @@ class CWallet final : public WalletStorage, public interfaces::Chain::Notificati
694
718
* Should be called with non-zero block_hash and posInBlock if this is for a transaction that is included in a block. */
695
719
void SyncTransaction (const CTransactionRef& tx, CWalletTx::Confirmation confirm, bool update_tx = true ) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
696
720
721
+ /* * WalletFlags set on this wallet. */
697
722
std::atomic<uint64_t > m_wallet_flags{0 };
698
723
699
724
bool SetAddressBookWithDB (WalletBatch& batch, const CTxDestination& address, const std::string& strName, const std::string& strPurpose);
@@ -753,8 +778,11 @@ class CWallet final : public WalletStorage, public interfaces::Chain::Notificati
753
778
754
779
/* *
755
780
* Select a set of coins such that nValueRet >= nTargetValue and at least
756
- * all coins from coinControl are selected; Never select unconfirmed coins
757
- * if they are not ours
781
+ * all coins from coin_control are selected; never select unconfirmed coins if they are not ours
782
+ * param@[out] setCoinsRet Populated with inputs including pre-selected inputs from
783
+ * coin_control and Coin Selection if successful.
784
+ * param@[out] nValueRet Total value of selected coins including pre-selected ones
785
+ * from coin_control and Coin Selection if successful.
758
786
*/
759
787
bool SelectCoins (const std::vector<COutput>& vAvailableCoins, const CAmount& nTargetValue, std::set<CInputCoin>& setCoinsRet, CAmount& nValueRet,
760
788
const CCoinControl& coin_control, CoinSelectionParams& coin_selection_params, bool & bnb_used) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
@@ -788,6 +816,8 @@ class CWallet final : public WalletStorage, public interfaces::Chain::Notificati
788
816
/* * Interface to assert chain access */
789
817
bool HaveChain () const { return m_chain ? true : false ; }
790
818
819
+ /* * Map from txid to CWalletTx for all transactions this wallet is
820
+ * interested in, including received and sent transactions. */
791
821
std::map<uint256, CWalletTx> mapWallet GUARDED_BY (cs_wallet);
792
822
793
823
typedef std::multimap<int64_t , CWalletTx*> TxItems;
@@ -799,6 +829,10 @@ class CWallet final : public WalletStorage, public interfaces::Chain::Notificati
799
829
std::map<CTxDestination, CAddressBookData> m_address_book GUARDED_BY (cs_wallet);
800
830
const CAddressBookData* FindAddressBookEntry (const CTxDestination&, bool allow_change = false ) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
801
831
832
+ /* * Set of Coins owned by this wallet that we won't try to spend from. A
833
+ * Coin may be locked if it has already been used to fund a transaction
834
+ * that hasn't confirmed yet. We wouldn't consider the Coin spent already,
835
+ * but also shouldn't try to use it again. */
802
836
std::set<COutPoint> setLockedCoins GUARDED_BY (cs_wallet);
803
837
804
838
/* * Registered interfaces::Chain::Notifications handler. */
@@ -833,6 +867,11 @@ class CWallet final : public WalletStorage, public interfaces::Chain::Notificati
833
867
* small change; This method is stochastic for some inputs and upon
834
868
* completion the coin set and corresponding actual target value is
835
869
* assembled
870
+ * param@[in] coins Set of UTXOs to consider. These will be categorized into
871
+ * OutputGroups and filtered using eligibility_filter before
872
+ * selecting coins.
873
+ * param@[out] setCoinsRet Populated with the coins selected if successful.
874
+ * param@[out] nValueRet Used to return the total value of selected coins.
836
875
*/
837
876
bool SelectCoinsMinConf (const CAmount& nTargetValue, const CoinEligibilityFilter& eligibility_filter, std::vector<COutput> coins,
838
877
std::set<CInputCoin>& setCoinsRet, CAmount& nValueRet, const CoinSelectionParams& coin_selection_params, bool & bnb_used) const ;
@@ -1015,6 +1054,8 @@ class CWallet final : public WalletStorage, public interfaces::Chain::Notificati
1015
1054
1016
1055
CFeeRate m_pay_tx_fee{DEFAULT_PAY_TX_FEE};
1017
1056
unsigned int m_confirm_target{DEFAULT_TX_CONFIRM_TARGET};
1057
+ /* * Allow Coin Selection to pick unconfirmed UTXOs that were sent from our own wallet if it
1058
+ * cannot fund the transaction otherwise. */
1018
1059
bool m_spend_zero_conf_change{DEFAULT_SPEND_ZEROCONF_CHANGE};
1019
1060
bool m_signal_rbf{DEFAULT_WALLET_RBF};
1020
1061
bool m_allow_fallback_fee{true }; // !< will be false if -fallbackfee=0
@@ -1025,7 +1066,12 @@ class CWallet final : public WalletStorage, public interfaces::Chain::Notificati
1025
1066
* Override with -fallbackfee
1026
1067
*/
1027
1068
CFeeRate m_fallback_fee{DEFAULT_FALLBACK_FEE};
1069
+
1070
+ /* * If the cost to spend a change output at this feerate is greater than the value of the
1071
+ * output itself, just drop it to fees. */
1028
1072
CFeeRate m_discard_rate{DEFAULT_DISCARD_FEE};
1073
+
1074
+ /* * The maximum fee amount we're willing to pay to prioritize partial spend avoidance. */
1029
1075
CAmount m_max_aps_fee{DEFAULT_MAX_AVOIDPARTIALSPEND_FEE}; // !< note: this is absolute fee, not fee rate
1030
1076
OutputType m_default_address_type{DEFAULT_ADDRESS_TYPE};
1031
1077
/* *
0 commit comments