mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-21 14:34:49 +01:00
rpc: extract wallet "warnings" fields to a util helper
This commit is contained in:
parent
f73782a903
commit
079d8cdda8
5 changed files with 18 additions and 4 deletions
|
@ -162,7 +162,7 @@ static RPCHelpMan createmultisig()
|
|||
// Only warns if the user has explicitly chosen an address type we cannot generate
|
||||
warnings.push_back("Unable to make chosen address type, please ensure no uncompressed public keys are present.");
|
||||
}
|
||||
if (!warnings.empty()) result.pushKV("warnings", warnings);
|
||||
PushWarnings(warnings, result);
|
||||
|
||||
return result;
|
||||
},
|
||||
|
|
|
@ -1174,3 +1174,9 @@ UniValue GetServicesNames(ServiceFlags services)
|
|||
|
||||
return servicesNames;
|
||||
}
|
||||
|
||||
void PushWarnings(const UniValue& warnings, UniValue& obj)
|
||||
{
|
||||
if (warnings.empty()) return;
|
||||
obj.pushKV("warnings", warnings);
|
||||
}
|
||||
|
|
|
@ -381,4 +381,12 @@ private:
|
|||
const RPCExamples m_examples;
|
||||
};
|
||||
|
||||
/**
|
||||
* Push warning messages to an RPC "warnings" field as a JSON array of strings.
|
||||
*
|
||||
* @param[in] warnings Warning messages to push.
|
||||
* @param[out] obj UniValue object to push the warnings array object to.
|
||||
*/
|
||||
void PushWarnings(const UniValue& warnings, UniValue& obj);
|
||||
|
||||
#endif // BITCOIN_RPC_UTIL_H
|
||||
|
|
|
@ -300,7 +300,7 @@ RPCHelpMan addmultisigaddress()
|
|||
// Only warns if the user has explicitly chosen an address type we cannot generate
|
||||
warnings.push_back("Unable to make chosen address type, please ensure no uncompressed public keys are present.");
|
||||
}
|
||||
if (!warnings.empty()) result.pushKV("warnings", warnings);
|
||||
PushWarnings(warnings, result);
|
||||
|
||||
return result;
|
||||
},
|
||||
|
|
|
@ -1225,7 +1225,7 @@ static UniValue ProcessImport(CWallet& wallet, const UniValue& data, const int64
|
|||
|
||||
result.pushKV("error", JSONRPCError(RPC_MISC_ERROR, "Missing required fields"));
|
||||
}
|
||||
if (warnings.size()) result.pushKV("warnings", warnings);
|
||||
PushWarnings(warnings, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -1579,7 +1579,7 @@ static UniValue ProcessDescriptorImport(CWallet& wallet, const UniValue& data, c
|
|||
result.pushKV("success", UniValue(false));
|
||||
result.pushKV("error", e);
|
||||
}
|
||||
if (warnings.size()) result.pushKV("warnings", warnings);
|
||||
PushWarnings(warnings, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue