aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Chow <github@achow101.com>2023-03-08 12:08:25 -0500
committerAndrew Chow <github@achow101.com>2023-03-08 12:15:31 -0500
commit1ff135ca7ff73080daeeaea8c19ccaa555eab487 (patch)
treebe9328f954bd7202de132ba32e7a250457d86877
parent8d12127a9c19cb218d661a88ab9b6871c9d853b9 (diff)
parentb082f28101773e0ef0281d97025e65d0364d6f29 (diff)
downloadbitcoin-1ff135ca7ff73080daeeaea8c19ccaa555eab487.tar.xz
Merge bitcoin/bitcoin#26194: rpc, wallet: use the same `next_index` key in `listdescriptors` and `importdescriptors`
b082f28101773e0ef0281d97025e65d0364d6f29 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 b082f28101773e0ef0281d97025e65d0364d6f29 aureleoules: reACK b082f28101773e0ef0281d97025e65d0364d6f29 Tree-SHA512: c29ec59051878e614d749ed6dc85e5c14ad00db0e8fcbce3f5066d1aae85ef07ca70f02920299e48d191b7387024fe224b0054c4191a5951cb805106f7b8e37b
-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 744537cfbd..09cfc07bc2 100644
--- a/src/wallet/rpc/backup.cpp
+++ b/src/wallet/rpc/backup.cpp
@@ -1760,7 +1760,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"},
}},
}}
}},
@@ -1837,6 +1838,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 fb2156bda1..c5479089c6 100755
--- a/test/functional/wallet_listdescriptors.py
+++ b/test/functional/wallet_listdescriptors.py
@@ -54,7 +54,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
@@ -78,7 +78,8 @@ class ListDescriptorsTest(BitcoinTestFramework):
'timestamp': TIME_GENESIS_BLOCK,
'active': False,
'range': [0, 0],
- 'next': 0},
+ 'next': 0,
+ 'next_index': 0},
],
}
assert_equal(expected, wallet.listdescriptors())
@@ -92,7 +93,8 @@ class ListDescriptorsTest(BitcoinTestFramework):
'timestamp': TIME_GENESIS_BLOCK,
'active': False,
'range': [0, 0],
- 'next': 0},
+ 'next': 0,
+ 'next_index': 0},
],
}
assert_equal(expected_private, wallet.listdescriptors(True))