0
0
Fork 0
mirror of https://github.com/bitcoin/bitcoin.git synced 2025-02-02 09:46:52 -05:00

Merge bitcoin/bitcoin#24855: rpc: Fix setwalletflag disabling of flags

88376c623c test: Test for disabling wallet flags (Andrew Chow)
17ab31aa46 rpc, wallet: setwalletflags warnings are optional (Andrew Chow)

Pull request description:

  Trying to disable a wallet flag with `setwalletflag` results in `Internal bug detected: 'std::any_of(m_results.m_results.begin(), m_results.m_results.end(), [ret](const RPCResult& res) { return res.MatchesType(ret); })'`. This occurs because the `warnings` field was not marked as optional. This PR makes `warnings` optional to avoid this error.

  Also added a test case because apparently we didn't already have one.

ACKs for top commit:
  w0xlt:
    ACK 88376c6

Tree-SHA512: 4f5d3bebf0d022a5ad0f75d70c6562a43c7da6e39e9c3118733327d015c435e2c8d5004fdb039d42407dde5b21231a0f8827623d718abf611a1f06c15af5c806
This commit is contained in:
fanquake 2022-04-16 10:45:01 +01:00
commit d1b3dfb275
No known key found for this signature in database
GPG key ID: 2EEB9F5CC09526C1
2 changed files with 12 additions and 1 deletions

View file

@ -257,7 +257,7 @@ static RPCHelpMan setwalletflag()
{
{RPCResult::Type::STR, "flag_name", "The name of the flag that was modified"},
{RPCResult::Type::BOOL, "flag_state", "The new state of the flag"},
{RPCResult::Type::STR, "warnings", "Any warnings associated with the change"},
{RPCResult::Type::STR, "warnings", /*optional=*/true, "Any warnings associated with the change"},
}
},
RPCExamples{

View file

@ -118,6 +118,17 @@ class AvoidReuseTest(BitcoinTestFramework):
assert_raises_rpc_error(-8, "Wallet flag is already set to false", self.nodes[0].setwalletflag, 'avoid_reuse', False)
assert_raises_rpc_error(-8, "Wallet flag is already set to true", self.nodes[1].setwalletflag, 'avoid_reuse', True)
# Create a wallet with avoid reuse, and test that disabling it afterwards persists
self.nodes[1].createwallet(wallet_name="avoid_reuse_persist", avoid_reuse=True)
w = self.nodes[1].get_wallet_rpc("avoid_reuse_persist")
assert_equal(w.getwalletinfo()["avoid_reuse"], True)
w.setwalletflag("avoid_reuse", False)
assert_equal(w.getwalletinfo()["avoid_reuse"], False)
w.unloadwallet()
self.nodes[1].loadwallet("avoid_reuse_persist")
assert_equal(w.getwalletinfo()["avoid_reuse"], False)
w.unloadwallet()
def test_immutable(self):
'''Test immutable wallet flags'''
self.log.info("Test immutable wallet flags")