Skip to content

Commit 1ff135c

Browse files
committed
Merge bitcoin/bitcoin#26194: rpc, wallet: use the same next_index key in listdescriptors and importdescriptors
b082f28 rpc, wallet: use the same `next_index` in listdescriptors and importdescriptors (w0xlt) Pull request description: Currently `listdescriptors` RPC uses `next` key to represent `WalletDescriptor::next_index` while `importdescriptors` uses `next_index`. This creates two different descriptor formats. This PR changes `listdescriptors` to use the same key as `importdescriptors`. ACKs for top commit: achow101: ACK b082f28 aureleoules: reACK b082f28 Tree-SHA512: c29ec59051878e614d749ed6dc85e5c14ad00db0e8fcbce3f5066d1aae85ef07ca70f02920299e48d191b7387024fe224b0054c4191a5951cb805106f7b8e37b
2 parents 8d12127 + b082f28 commit 1ff135c

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

doc/release-note-26194.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Add `next_index` in `listdescriptors` RPC
2+
-----------------
3+
4+
- Added a new `next_index` field in the response in `listdescriptors` to have the same format as `importdescriptors`

src/wallet/rpc/backup.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1760,7 +1760,8 @@ RPCHelpMan listdescriptors()
17601760
{RPCResult::Type::NUM, "", "Range start inclusive"},
17611761
{RPCResult::Type::NUM, "", "Range end inclusive"},
17621762
}},
1763-
{RPCResult::Type::NUM, "next", /*optional=*/true, "The next index to generate addresses from; defined only for ranged descriptors"},
1763+
{RPCResult::Type::NUM, "next", /*optional=*/true, "Same as next_index field. Kept for compatibility reason."},
1764+
{RPCResult::Type::NUM, "next_index", /*optional=*/true, "The next index to generate addresses from; defined only for ranged descriptors"},
17641765
}},
17651766
}}
17661767
}},
@@ -1837,6 +1838,7 @@ RPCHelpMan listdescriptors()
18371838
range.push_back(info.range->second - 1);
18381839
spk.pushKV("range", range);
18391840
spk.pushKV("next", info.next_index);
1841+
spk.pushKV("next_index", info.next_index);
18401842
}
18411843
descriptors.push_back(spk);
18421844
}

test/functional/wallet_listdescriptors.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def run_test(self):
5454
assert_equal(4, len([d for d in result['descriptors'] if d['internal']]))
5555
for item in result['descriptors']:
5656
assert item['desc'] != ''
57-
assert item['next'] == 0
57+
assert item['next_index'] == 0
5858
assert item['range'] == [0, 0]
5959
assert item['timestamp'] is not None
6060

@@ -78,7 +78,8 @@ def run_test(self):
7878
'timestamp': TIME_GENESIS_BLOCK,
7979
'active': False,
8080
'range': [0, 0],
81-
'next': 0},
81+
'next': 0,
82+
'next_index': 0},
8283
],
8384
}
8485
assert_equal(expected, wallet.listdescriptors())
@@ -92,7 +93,8 @@ def run_test(self):
9293
'timestamp': TIME_GENESIS_BLOCK,
9394
'active': False,
9495
'range': [0, 0],
95-
'next': 0},
96+
'next': 0,
97+
'next_index': 0},
9698
],
9799
}
98100
assert_equal(expected_private, wallet.listdescriptors(True))

0 commit comments

Comments
 (0)