2222#include < util/bip32.h>
2323#include < util/fees.h>
2424#include < util/moneystr.h>
25+ #include < util/string.h>
2526#include < util/system.h>
2627#include < util/url.h>
2728#include < util/validation.h>
@@ -2587,13 +2588,14 @@ static UniValue loadwallet(const JSONRPCRequest& request)
25872588 }
25882589 }
25892590
2590- std::string error, warning;
2591+ std::string error;
2592+ std::vector<std::string> warning;
25912593 std::shared_ptr<CWallet> const wallet = LoadWallet (*g_rpc_interfaces->chain , location, error, warning);
25922594 if (!wallet) throw JSONRPCError (RPC_WALLET_ERROR, error);
25932595
25942596 UniValue obj (UniValue::VOBJ);
25952597 obj.pushKV (" name" , wallet->GetName ());
2596- obj.pushKV (" warning" , warning);
2598+ obj.pushKV (" warning" , Join ( warning, " \n " ) );
25972599
25982600 return obj;
25992601}
@@ -2699,12 +2701,12 @@ static UniValue createwallet(const JSONRPCRequest& request)
26992701 }
27002702 SecureString passphrase;
27012703 passphrase.reserve (100 );
2702- std::string warning ;
2704+ std::vector<std:: string> warnings ;
27032705 if (!request.params [3 ].isNull ()) {
27042706 passphrase = request.params [3 ].get_str ().c_str ();
27052707 if (passphrase.empty ()) {
27062708 // Empty string means unencrypted
2707- warning = " Empty string given as passphrase, wallet will not be encrypted." ;
2709+ warnings. emplace_back ( " Empty string given as passphrase, wallet will not be encrypted." ) ;
27082710 }
27092711 }
27102712
@@ -2713,9 +2715,8 @@ static UniValue createwallet(const JSONRPCRequest& request)
27132715 }
27142716
27152717 std::string error;
2716- std::string create_warning;
27172718 std::shared_ptr<CWallet> wallet;
2718- WalletCreationStatus status = CreateWallet (*g_rpc_interfaces->chain , passphrase, flags, request.params [0 ].get_str (), error, create_warning , wallet);
2719+ WalletCreationStatus status = CreateWallet (*g_rpc_interfaces->chain , passphrase, flags, request.params [0 ].get_str (), error, warnings , wallet);
27192720 switch (status) {
27202721 case WalletCreationStatus::CREATION_FAILED:
27212722 throw JSONRPCError (RPC_WALLET_ERROR, error);
@@ -2726,15 +2727,9 @@ static UniValue createwallet(const JSONRPCRequest& request)
27262727 // no default case, so the compiler can warn about missing cases
27272728 }
27282729
2729- if (warning.empty ()) {
2730- warning = create_warning;
2731- } else if (!warning.empty () && !create_warning.empty ()){
2732- warning += " ; " + create_warning;
2733- }
2734-
27352730 UniValue obj (UniValue::VOBJ);
27362731 obj.pushKV (" name" , wallet->GetName ());
2737- obj.pushKV (" warning" , warning );
2732+ obj.pushKV (" warning" , Join (warnings, " \n " ) );
27382733
27392734 return obj;
27402735}
0 commit comments