Skip to content

Commit b082f28

Browse files
committed
rpc, wallet: use the same next_index in listdescriptors and importdescriptors
1 parent 9fcdb9f commit b082f28

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
@@ -1771,7 +1771,8 @@ RPCHelpMan listdescriptors()
17711771
{RPCResult::Type::NUM, "", "Range start inclusive"},
17721772
{RPCResult::Type::NUM, "", "Range end inclusive"},
17731773
}},
1774-
{RPCResult::Type::NUM, "next", /*optional=*/true, "The next index to generate addresses from; defined only for ranged descriptors"},
1774+
{RPCResult::Type::NUM, "next", /*optional=*/true, "Same as next_index field. Kept for compatibility reason."},
1775+
{RPCResult::Type::NUM, "next_index", /*optional=*/true, "The next index to generate addresses from; defined only for ranged descriptors"},
17751776
}},
17761777
}}
17771778
}},
@@ -1848,6 +1849,7 @@ RPCHelpMan listdescriptors()
18481849
range.push_back(info.range->second - 1);
18491850
spk.pushKV("range", range);
18501851
spk.pushKV("next", info.next_index);
1852+
spk.pushKV("next_index", info.next_index);
18511853
}
18521854
descriptors.push_back(spk);
18531855
}

test/functional/wallet_listdescriptors.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def run_test(self):
4848
assert_equal(4, len([d for d in result['descriptors'] if d['internal']]))
4949
for item in result['descriptors']:
5050
assert item['desc'] != ''
51-
assert item['next'] == 0
51+
assert item['next_index'] == 0
5252
assert item['range'] == [0, 0]
5353
assert item['timestamp'] is not None
5454

@@ -72,7 +72,8 @@ def run_test(self):
7272
'timestamp': 1296688602,
7373
'active': False,
7474
'range': [0, 0],
75-
'next': 0},
75+
'next': 0,
76+
'next_index': 0},
7677
],
7778
}
7879
assert_equal(expected, wallet.listdescriptors())
@@ -86,7 +87,8 @@ def run_test(self):
8687
'timestamp': 1296688602,
8788
'active': False,
8889
'range': [0, 0],
89-
'next': 0},
90+
'next': 0,
91+
'next_index': 0},
9092
],
9193
}
9294
assert_equal(expected_private, wallet.listdescriptors(True))

0 commit comments

Comments
 (0)