aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorw0xlt <woltx@protonmail.com>2022-09-28 12:10:33 -0300
committerw0xlt <woltx@protonmail.com>2022-12-06 11:38:07 -0300
commitb082f28101773e0ef0281d97025e65d0364d6f29 (patch)
tree20fccded6a15e9635e8c1f1bf95844f9d4572b06
parent9fcdb9f3a044330d3d7515fa35709102c98534d2 (diff)
downloadbitcoin-b082f28101773e0ef0281d97025e65d0364d6f29.tar.xz
rpc, wallet: use the same `next_index` in listdescriptors and importdescriptors
-rw-r--r--doc/release-note-26194.md4
-rw-r--r--src/wallet/rpc/backup.cpp4
-rwxr-xr-xtest/functional/wallet_listdescriptors.py8
3 files changed, 12 insertions, 4 deletions
diff --git a/doc/release-note-26194.md b/doc/release-note-26194.md
new file mode 100644
index 0000000000..b72dbf9a23
--- /dev/null
+++ b/doc/release-note-26194.md
@@ -0,0 +1,4 @@
+Add `next_index` in `listdescriptors` RPC
+-----------------
+
+- Added a new `next_index` field in the response in `listdescriptors` to have the same format as `importdescriptors`
diff --git a/src/wallet/rpc/backup.cpp b/src/wallet/rpc/backup.cpp
index 6cc3a71e19..4da129225f 100644
--- a/src/wallet/rpc/backup.cpp
+++ b/src/wallet/rpc/backup.cpp
@@ -1771,7 +1771,8 @@ RPCHelpMan listdescriptors()
{RPCResult::Type::NUM, "", "Range start inclusive"},
{RPCResult::Type::NUM, "", "Range end inclusive"},
}},
- {RPCResult::Type::NUM, "next", /*optional=*/true, "The next index to generate addresses from; defined only for ranged descriptors"},
+ {RPCResult::Type::NUM, "next", /*optional=*/true, "Same as next_index field. Kept for compatibility reason."},
+ {RPCResult::Type::NUM, "next_index", /*optional=*/true, "The next index to generate addresses from; defined only for ranged descriptors"},
}},
}}
}},
@@ -1848,6 +1849,7 @@ RPCHelpMan listdescriptors()
range.push_back(info.range->second - 1);
spk.pushKV("range", range);
spk.pushKV("next", info.next_index);
+ spk.pushKV("next_index", info.next_index);
}
descriptors.push_back(spk);
}
diff --git a/test/functional/wallet_listdescriptors.py b/test/functional/wallet_listdescriptors.py
index d5372f5aee..c0de3b2af0 100755
--- a/test/functional/wallet_listdescriptors.py
+++ b/test/functional/wallet_listdescriptors.py
@@ -48,7 +48,7 @@ class ListDescriptorsTest(BitcoinTestFramework):
assert_equal(4, len([d for d in result['descriptors'] if d['internal']]))
for item in result['descriptors']:
assert item['desc'] != ''
- assert item['next'] == 0
+ assert item['next_index'] == 0
assert item['range'] == [0, 0]
assert item['timestamp'] is not None
@@ -72,7 +72,8 @@ class ListDescriptorsTest(BitcoinTestFramework):
'timestamp': 1296688602,
'active': False,
'range': [0, 0],
- 'next': 0},
+ 'next': 0,
+ 'next_index': 0},
],
}
assert_equal(expected, wallet.listdescriptors())
@@ -86,7 +87,8 @@ class ListDescriptorsTest(BitcoinTestFramework):
'timestamp': 1296688602,
'active': False,
'range': [0, 0],
- 'next': 0},
+ 'next': 0,
+ 'next_index': 0},
],
}
assert_equal(expected_private, wallet.listdescriptors(True))