aboutsummaryrefslogtreecommitdiff
path: root/test/functional/rpc_deriveaddresses.py
diff options
context:
space:
mode:
authormuxator <antonio.muci@bancaditalia.it>2022-10-06 12:03:36 +0200
committermuxator <antonio.muci@bancaditalia.it>2022-10-06 12:03:36 +0200
commit9153ff3e274953ea0d92d53ddab4c72deeace1b1 (patch)
treeee1d4d5dcb701d2c69d4e5fb8a58efd0e29d516c /test/functional/rpc_deriveaddresses.py
parentaddf9d6502db12cebcc5976df3111cac1a369b82 (diff)
downloadbitcoin-9153ff3e274953ea0d92d53ddab4c72deeace1b1.tar.xz
rpc: add non-regression test about deriveaddresses crash when index is 2147483647
This test would cause a crash in bitcoind (see #26274) if the fix given in the previous commit was not applied.
Diffstat (limited to 'test/functional/rpc_deriveaddresses.py')
-rwxr-xr-xtest/functional/rpc_deriveaddresses.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/test/functional/rpc_deriveaddresses.py b/test/functional/rpc_deriveaddresses.py
index 42d7d59d56..a69326736d 100755
--- a/test/functional/rpc_deriveaddresses.py
+++ b/test/functional/rpc_deriveaddresses.py
@@ -44,6 +44,13 @@ class DeriveaddressesTest(BitcoinTestFramework):
combo_descriptor = descsum_create("combo(tprv8ZgxMBicQKsPd7Uf69XL1XwhmjHopUGep8GuEiJDZmbQz6o58LninorQAfcKZWARbtRtfnLcJ5MQ2AtHcQJCCRUcMRvmDUjyEmNUWwx8UbK/1/1/0)")
assert_equal(self.nodes[0].deriveaddresses(combo_descriptor), ["mtfUoUax9L4tzXARpw1oTGxWyoogp52KhJ", "mtfUoUax9L4tzXARpw1oTGxWyoogp52KhJ", address, "2NDvEwGfpEqJWfybzpKPHF2XH3jwoQV3D7x"])
+ # Before #26275, bitcoind would crash when deriveaddresses was
+ # called with derivation index 2147483647, which is the maximum
+ # positive value of a signed int32, and - currently - the
+ # maximum value that the deriveaddresses bitcoin RPC call
+ # accepts as derivation index.
+ assert_equal(self.nodes[0].deriveaddresses(descsum_create("wpkh(tprv8ZgxMBicQKsPd7Uf69XL1XwhmjHopUGep8GuEiJDZmbQz6o58LninorQAfcKZWARbtRtfnLcJ5MQ2AtHcQJCCRUcMRvmDUjyEmNUWwx8UbK/1/1/*)"), [2147483647, 2147483647]), ["bcrt1qtzs23vgzpreks5gtygwxf8tv5rldxvvsyfpdkg"])
+
hardened_without_privkey_descriptor = descsum_create("wpkh(tpubD6NzVbkrYhZ4WaWSyoBvQwbpLkojyoTZPRsgXELWz3Popb3qkjcJyJUGLnL4qHHoQvao8ESaAstxYSnhyswJ76uZPStJRJCTKvosUCJZL5B/1'/1/0)")
assert_raises_rpc_error(-5, "Cannot derive script without private keys", self.nodes[0].deriveaddresses, hardened_without_privkey_descriptor)