aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorSebastian Falbesoner <sebastian.falbesoner@gmail.com>2023-08-24 16:46:36 +0200
committerSebastian Falbesoner <sebastian.falbesoner@gmail.com>2024-02-09 13:35:23 +0100
commit98570fe29bb08d7edc48011aa6b9731c6ab4ed2e (patch)
tree79cec2b0d0c08a20c83afea3b0338655532fc773 /test
parentc740b154d193b91ca42f18759098d3fef6eaab05 (diff)
downloadbitcoin-98570fe29bb08d7edc48011aa6b9731c6ab4ed2e.tar.xz
test: add coverage for parsing cryptographically invalid pubkeys
Diffstat (limited to 'test')
-rwxr-xr-xtest/functional/wallet_basic.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/test/functional/wallet_basic.py b/test/functional/wallet_basic.py
index dbb78e8d35..3daec4dbd1 100755
--- a/test/functional/wallet_basic.py
+++ b/test/functional/wallet_basic.py
@@ -461,9 +461,11 @@ class WalletTest(BitcoinTestFramework):
# This will raise an exception for attempting to import a pubkey that isn't in hex
assert_raises_rpc_error(-5, 'Pubkey "not hex" must be a hex string', self.nodes[0].importpubkey, "not hex")
- # This will raise an exception for importing a pubkey with invalid length
+ # This will raise exceptions for importing a pubkeys with invalid length / invalid coordinates
too_short_pubkey = "5361746f736869204e616b616d6f746f"
assert_raises_rpc_error(-5, f'Pubkey "{too_short_pubkey}" must have a length of either 33 or 65 bytes', self.nodes[0].importpubkey, too_short_pubkey)
+ not_on_curve_pubkey = bytes([4] + [0]*64).hex() # pubkey with coordinates (0,0) is not on curve
+ assert_raises_rpc_error(-5, f'Pubkey "{not_on_curve_pubkey}" must be cryptographically valid', self.nodes[0].importpubkey, not_on_curve_pubkey)
# Bech32m addresses cannot be imported into a legacy wallet
assert_raises_rpc_error(-5, "Bech32m addresses cannot be imported into legacy wallets", self.nodes[0].importaddress, "bcrt1p0xlxvlhemja6c4dqv22uapctqupfhlxm9h8z3k2e72q4k9hcz7vqc8gma6")