Skip to content

Commit d1b3dfb

Browse files
committed
Merge bitcoin/bitcoin#24855: rpc: Fix setwalletflag disabling of flags
88376c6 test: Test for disabling wallet flags (Andrew Chow) 17ab31a 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
2 parents 6be319b + 88376c6 commit d1b3dfb

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/wallet/rpc/wallet.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ static RPCHelpMan setwalletflag()
257257
{
258258
{RPCResult::Type::STR, "flag_name", "The name of the flag that was modified"},
259259
{RPCResult::Type::BOOL, "flag_state", "The new state of the flag"},
260-
{RPCResult::Type::STR, "warnings", "Any warnings associated with the change"},
260+
{RPCResult::Type::STR, "warnings", /*optional=*/true, "Any warnings associated with the change"},
261261
}
262262
},
263263
RPCExamples{

test/functional/wallet_avoidreuse.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,17 @@ def test_persistence(self):
118118
assert_raises_rpc_error(-8, "Wallet flag is already set to false", self.nodes[0].setwalletflag, 'avoid_reuse', False)
119119
assert_raises_rpc_error(-8, "Wallet flag is already set to true", self.nodes[1].setwalletflag, 'avoid_reuse', True)
120120

121+
# Create a wallet with avoid reuse, and test that disabling it afterwards persists
122+
self.nodes[1].createwallet(wallet_name="avoid_reuse_persist", avoid_reuse=True)
123+
w = self.nodes[1].get_wallet_rpc("avoid_reuse_persist")
124+
assert_equal(w.getwalletinfo()["avoid_reuse"], True)
125+
w.setwalletflag("avoid_reuse", False)
126+
assert_equal(w.getwalletinfo()["avoid_reuse"], False)
127+
w.unloadwallet()
128+
self.nodes[1].loadwallet("avoid_reuse_persist")
129+
assert_equal(w.getwalletinfo()["avoid_reuse"], False)
130+
w.unloadwallet()
131+
121132
def test_immutable(self):
122133
'''Test immutable wallet flags'''
123134
self.log.info("Test immutable wallet flags")

0 commit comments

Comments
 (0)