@@ -2510,6 +2510,7 @@ std::unique_ptr<WalletDatabase> MakeWalletDatabase(const std::string& name, cons
2510
2510
std::shared_ptr<CWallet> CWallet::Create (WalletContext& context, const std::string& name, std::unique_ptr<WalletDatabase> database, uint64_t wallet_creation_flags, bilingual_str& error, std::vector<bilingual_str>& warnings)
2511
2511
{
2512
2512
interfaces::Chain* chain = context.chain ;
2513
+ ArgsManager& args = *Assert (context.args );
2513
2514
const std::string& walletFile = database->Filename ();
2514
2515
2515
2516
int64_t nStart = GetTimeMillis ();
@@ -2591,28 +2592,28 @@ std::shared_ptr<CWallet> CWallet::Create(WalletContext& context, const std::stri
2591
2592
}
2592
2593
}
2593
2594
2594
- if (!gArgs .GetArg (" -addresstype" , " " ).empty ()) {
2595
- std::optional<OutputType> parsed = ParseOutputType (gArgs .GetArg (" -addresstype" , " " ));
2595
+ if (!args .GetArg (" -addresstype" , " " ).empty ()) {
2596
+ std::optional<OutputType> parsed = ParseOutputType (args .GetArg (" -addresstype" , " " ));
2596
2597
if (!parsed) {
2597
- error = strprintf (_ (" Unknown address type '%s'" ), gArgs .GetArg (" -addresstype" , " " ));
2598
+ error = strprintf (_ (" Unknown address type '%s'" ), args .GetArg (" -addresstype" , " " ));
2598
2599
return nullptr ;
2599
2600
}
2600
2601
walletInstance->m_default_address_type = parsed.value ();
2601
2602
}
2602
2603
2603
- if (!gArgs .GetArg (" -changetype" , " " ).empty ()) {
2604
- std::optional<OutputType> parsed = ParseOutputType (gArgs .GetArg (" -changetype" , " " ));
2604
+ if (!args .GetArg (" -changetype" , " " ).empty ()) {
2605
+ std::optional<OutputType> parsed = ParseOutputType (args .GetArg (" -changetype" , " " ));
2605
2606
if (!parsed) {
2606
- error = strprintf (_ (" Unknown change type '%s'" ), gArgs .GetArg (" -changetype" , " " ));
2607
+ error = strprintf (_ (" Unknown change type '%s'" ), args .GetArg (" -changetype" , " " ));
2607
2608
return nullptr ;
2608
2609
}
2609
2610
walletInstance->m_default_change_type = parsed.value ();
2610
2611
}
2611
2612
2612
- if (gArgs .IsArgSet (" -mintxfee" )) {
2613
- std::optional<CAmount> min_tx_fee = ParseMoney (gArgs .GetArg (" -mintxfee" , " " ));
2613
+ if (args .IsArgSet (" -mintxfee" )) {
2614
+ std::optional<CAmount> min_tx_fee = ParseMoney (args .GetArg (" -mintxfee" , " " ));
2614
2615
if (!min_tx_fee || min_tx_fee.value () == 0 ) {
2615
- error = AmountErrMsg (" mintxfee" , gArgs .GetArg (" -mintxfee" , " " ));
2616
+ error = AmountErrMsg (" mintxfee" , args .GetArg (" -mintxfee" , " " ));
2616
2617
return nullptr ;
2617
2618
} else if (min_tx_fee.value () > HIGH_TX_FEE_PER_KB) {
2618
2619
warnings.push_back (AmountHighWarn (" -mintxfee" ) + Untranslated (" " ) +
@@ -2622,8 +2623,8 @@ std::shared_ptr<CWallet> CWallet::Create(WalletContext& context, const std::stri
2622
2623
walletInstance->m_min_fee = CFeeRate{min_tx_fee.value ()};
2623
2624
}
2624
2625
2625
- if (gArgs .IsArgSet (" -maxapsfee" )) {
2626
- const std::string max_aps_fee{gArgs .GetArg (" -maxapsfee" , " " )};
2626
+ if (args .IsArgSet (" -maxapsfee" )) {
2627
+ const std::string max_aps_fee{args .GetArg (" -maxapsfee" , " " )};
2627
2628
if (max_aps_fee == " -1" ) {
2628
2629
walletInstance->m_max_aps_fee = -1 ;
2629
2630
} else if (std::optional<CAmount> max_fee = ParseMoney (max_aps_fee)) {
@@ -2638,10 +2639,10 @@ std::shared_ptr<CWallet> CWallet::Create(WalletContext& context, const std::stri
2638
2639
}
2639
2640
}
2640
2641
2641
- if (gArgs .IsArgSet (" -fallbackfee" )) {
2642
- std::optional<CAmount> fallback_fee = ParseMoney (gArgs .GetArg (" -fallbackfee" , " " ));
2642
+ if (args .IsArgSet (" -fallbackfee" )) {
2643
+ std::optional<CAmount> fallback_fee = ParseMoney (args .GetArg (" -fallbackfee" , " " ));
2643
2644
if (!fallback_fee) {
2644
- error = strprintf (_ (" Invalid amount for -fallbackfee=<amount>: '%s'" ), gArgs .GetArg (" -fallbackfee" , " " ));
2645
+ error = strprintf (_ (" Invalid amount for -fallbackfee=<amount>: '%s'" ), args .GetArg (" -fallbackfee" , " " ));
2645
2646
return nullptr ;
2646
2647
} else if (fallback_fee.value () > HIGH_TX_FEE_PER_KB) {
2647
2648
warnings.push_back (AmountHighWarn (" -fallbackfee" ) + Untranslated (" " ) +
@@ -2653,10 +2654,10 @@ std::shared_ptr<CWallet> CWallet::Create(WalletContext& context, const std::stri
2653
2654
// Disable fallback fee in case value was set to 0, enable if non-null value
2654
2655
walletInstance->m_allow_fallback_fee = walletInstance->m_fallback_fee .GetFeePerK () != 0 ;
2655
2656
2656
- if (gArgs .IsArgSet (" -discardfee" )) {
2657
- std::optional<CAmount> discard_fee = ParseMoney (gArgs .GetArg (" -discardfee" , " " ));
2657
+ if (args .IsArgSet (" -discardfee" )) {
2658
+ std::optional<CAmount> discard_fee = ParseMoney (args .GetArg (" -discardfee" , " " ));
2658
2659
if (!discard_fee) {
2659
- error = strprintf (_ (" Invalid amount for -discardfee=<amount>: '%s'" ), gArgs .GetArg (" -discardfee" , " " ));
2660
+ error = strprintf (_ (" Invalid amount for -discardfee=<amount>: '%s'" ), args .GetArg (" -discardfee" , " " ));
2660
2661
return nullptr ;
2661
2662
} else if (discard_fee.value () > HIGH_TX_FEE_PER_KB) {
2662
2663
warnings.push_back (AmountHighWarn (" -discardfee" ) + Untranslated (" " ) +
@@ -2665,10 +2666,10 @@ std::shared_ptr<CWallet> CWallet::Create(WalletContext& context, const std::stri
2665
2666
walletInstance->m_discard_rate = CFeeRate{discard_fee.value ()};
2666
2667
}
2667
2668
2668
- if (gArgs .IsArgSet (" -paytxfee" )) {
2669
- std::optional<CAmount> pay_tx_fee = ParseMoney (gArgs .GetArg (" -paytxfee" , " " ));
2669
+ if (args .IsArgSet (" -paytxfee" )) {
2670
+ std::optional<CAmount> pay_tx_fee = ParseMoney (args .GetArg (" -paytxfee" , " " ));
2670
2671
if (!pay_tx_fee) {
2671
- error = AmountErrMsg (" paytxfee" , gArgs .GetArg (" -paytxfee" , " " ));
2672
+ error = AmountErrMsg (" paytxfee" , args .GetArg (" -paytxfee" , " " ));
2672
2673
return nullptr ;
2673
2674
} else if (pay_tx_fee.value () > HIGH_TX_FEE_PER_KB) {
2674
2675
warnings.push_back (AmountHighWarn (" -paytxfee" ) + Untranslated (" " ) +
@@ -2679,23 +2680,23 @@ std::shared_ptr<CWallet> CWallet::Create(WalletContext& context, const std::stri
2679
2680
2680
2681
if (chain && walletInstance->m_pay_tx_fee < chain->relayMinFee ()) {
2681
2682
error = strprintf (_ (" Invalid amount for -paytxfee=<amount>: '%s' (must be at least %s)" ),
2682
- gArgs .GetArg (" -paytxfee" , " " ), chain->relayMinFee ().ToString ());
2683
+ args .GetArg (" -paytxfee" , " " ), chain->relayMinFee ().ToString ());
2683
2684
return nullptr ;
2684
2685
}
2685
2686
}
2686
2687
2687
- if (gArgs .IsArgSet (" -maxtxfee" )) {
2688
- std::optional<CAmount> max_fee = ParseMoney (gArgs .GetArg (" -maxtxfee" , " " ));
2688
+ if (args .IsArgSet (" -maxtxfee" )) {
2689
+ std::optional<CAmount> max_fee = ParseMoney (args .GetArg (" -maxtxfee" , " " ));
2689
2690
if (!max_fee) {
2690
- error = AmountErrMsg (" maxtxfee" , gArgs .GetArg (" -maxtxfee" , " " ));
2691
+ error = AmountErrMsg (" maxtxfee" , args .GetArg (" -maxtxfee" , " " ));
2691
2692
return nullptr ;
2692
2693
} else if (max_fee.value () > HIGH_MAX_TX_FEE) {
2693
2694
warnings.push_back (_ (" -maxtxfee is set very high! Fees this large could be paid on a single transaction." ));
2694
2695
}
2695
2696
2696
2697
if (chain && CFeeRate{max_fee.value (), 1000 } < chain->relayMinFee ()) {
2697
2698
error = strprintf (_ (" Invalid amount for -maxtxfee=<amount>: '%s' (must be at least the minrelay fee of %s to prevent stuck transactions)" ),
2698
- gArgs .GetArg (" -maxtxfee" , " " ), chain->relayMinFee ().ToString ());
2699
+ args .GetArg (" -maxtxfee" , " " ), chain->relayMinFee ().ToString ());
2699
2700
return nullptr ;
2700
2701
}
2701
2702
@@ -2707,9 +2708,9 @@ std::shared_ptr<CWallet> CWallet::Create(WalletContext& context, const std::stri
2707
2708
_ (" The wallet will avoid paying less than the minimum relay fee." ));
2708
2709
}
2709
2710
2710
- walletInstance->m_confirm_target = gArgs .GetArg (" -txconfirmtarget" , DEFAULT_TX_CONFIRM_TARGET);
2711
- walletInstance->m_spend_zero_conf_change = gArgs .GetBoolArg (" -spendzeroconfchange" , DEFAULT_SPEND_ZEROCONF_CHANGE);
2712
- walletInstance->m_signal_rbf = gArgs .GetBoolArg (" -walletrbf" , DEFAULT_WALLET_RBF);
2711
+ walletInstance->m_confirm_target = args .GetArg (" -txconfirmtarget" , DEFAULT_TX_CONFIRM_TARGET);
2712
+ walletInstance->m_spend_zero_conf_change = args .GetBoolArg (" -spendzeroconfchange" , DEFAULT_SPEND_ZEROCONF_CHANGE);
2713
+ walletInstance->m_signal_rbf = args .GetBoolArg (" -walletrbf" , DEFAULT_WALLET_RBF);
2713
2714
2714
2715
walletInstance->WalletLogPrintf (" Wallet completed loading in %15dms\n " , GetTimeMillis () - nStart);
2715
2716
@@ -2729,7 +2730,7 @@ std::shared_ptr<CWallet> CWallet::Create(WalletContext& context, const std::stri
2729
2730
}
2730
2731
}
2731
2732
2732
- walletInstance->SetBroadcastTransactions (gArgs .GetBoolArg (" -walletbroadcast" , DEFAULT_WALLETBROADCAST));
2733
+ walletInstance->SetBroadcastTransactions (args .GetBoolArg (" -walletbroadcast" , DEFAULT_WALLETBROADCAST));
2733
2734
2734
2735
{
2735
2736
walletInstance->WalletLogPrintf (" setKeyPool.size() = %u\n " , walletInstance->GetKeyPoolSize ());
0 commit comments