Skip to content

Commit 98570fe

Browse files
committed
test: add coverage for parsing cryptographically invalid pubkeys
1 parent c740b15 commit 98570fe

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

test/functional/wallet_basic.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,9 +461,11 @@ def run_test(self):
461461
# This will raise an exception for attempting to import a pubkey that isn't in hex
462462
assert_raises_rpc_error(-5, 'Pubkey "not hex" must be a hex string', self.nodes[0].importpubkey, "not hex")
463463

464-
# This will raise an exception for importing a pubkey with invalid length
464+
# This will raise exceptions for importing a pubkeys with invalid length / invalid coordinates
465465
too_short_pubkey = "5361746f736869204e616b616d6f746f"
466466
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)
467+
not_on_curve_pubkey = bytes([4] + [0]*64).hex() # pubkey with coordinates (0,0) is not on curve
468+
assert_raises_rpc_error(-5, f'Pubkey "{not_on_curve_pubkey}" must be cryptographically valid', self.nodes[0].importpubkey, not_on_curve_pubkey)
467469

468470
# Bech32m addresses cannot be imported into a legacy wallet
469471
assert_raises_rpc_error(-5, "Bech32m addresses cannot be imported into legacy wallets", self.nodes[0].importaddress, "bcrt1p0xlxvlhemja6c4dqv22uapctqupfhlxm9h8z3k2e72q4k9hcz7vqc8gma6")

0 commit comments

Comments
 (0)