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