Repository navigation
BIP 350: Implement Bech32m and use it for v1+ segwit addresses (0.21 backport) - #21469
Conversation
d520f73 to
28b3a32
Compare
|
utACK 28b3a32060 I repeated the backport myself and got the same result. You could also pick the rpc_invalid_address_message.py#!/usr/bin/env python3
# Copyright (c) 2020 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test error messages for 'getaddressinfo' and 'validateaddress' RPC commands."""
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
assert_equal,
assert_raises_rpc_error,
)
BECH32_VALID = 'bcrt1qtmp74ayg7p24uslctssvjm06q5phz4yrxucgnv'
BECH32_INVALID_BECH32 = 'bcrt1p0xlxvlhemja6c4dqv22uapctqupfhlxm9h8z3k2e72q4k9hcz7vqdmchcc'
BECH32_INVALID_BECH32M = 'bcrt1qw508d6qejxtdg4y5r3zarvary0c5xw7k35mrzd'
BECH32_INVALID_VERSION = 'bcrt130xlxvlhemja6c4dqv22uapctqupfhlxm9h8z3k2e72q4k9hcz7vqynjegk'
BECH32_INVALID_SIZE = 'bcrt1s0xlxvlhemja6c4dqv22uapctqupfhlxm9h8z3k2e72q4k9hcz7v8n0nx0muaewav25430mtr'
BECH32_INVALID_V0_SIZE = 'bcrt1qw508d6qejxtdg4y5r3zarvary0c5xw7kqqq5k3my'
BECH32_INVALID_PREFIX = 'bc1pw508d6qejxtdg4y5r3zarvary0c5xw7kw508d6qejxtdg4y5r3zarvary0c5xw7k7grplx'
BASE58_VALID = 'mipcBbFg9gMiCh81Kj8tqqdgoZub1ZJRfn'
BASE58_INVALID_PREFIX = '17VZNX1SN5NtKa8UQFxwQbFeFc3iqRYhem'
INVALID_ADDRESS = 'asfah14i8fajz0123f'
class InvalidAddressErrorMessageTest(BitcoinTestFramework):
def set_test_params(self):
self.setup_clean_chain = True
self.num_nodes = 1
def skip_test_if_missing_module(self):
self.skip_if_no_wallet()
def test_validateaddress(self):
node = self.nodes[0]
# Bech32
info = node.validateaddress(BECH32_INVALID_SIZE)
assert not info['isvalid']
info = node.validateaddress(BECH32_INVALID_PREFIX)
assert not info['isvalid']
info = node.validateaddress(BECH32_INVALID_BECH32)
assert not info['isvalid']
info = node.validateaddress(BECH32_INVALID_BECH32M)
assert not info['isvalid']
info = node.validateaddress(BECH32_INVALID_V0_SIZE)
assert not info['isvalid']
info = node.validateaddress(BECH32_VALID)
assert info['isvalid']
assert 'error' not in info
# Base58
info = node.validateaddress(BASE58_INVALID_PREFIX)
assert not info['isvalid']
info = node.validateaddress(BASE58_VALID)
assert info['isvalid']
assert 'error' not in info
# Invalid address format
info = node.validateaddress(INVALID_ADDRESS)
assert not info['isvalid']
def test_getaddressinfo(self):
node = self.nodes[0]
assert_raises_rpc_error(-5, "Invalid address", node.getaddressinfo, BECH32_INVALID_SIZE)
assert_raises_rpc_error(-5, "Invalid address", node.getaddressinfo, BECH32_INVALID_PREFIX)
assert_raises_rpc_error(-5, "Invalid address", node.getaddressinfo, BASE58_INVALID_PREFIX)
assert_raises_rpc_error(-5, "Invalid address", node.getaddressinfo, INVALID_ADDRESS)
def run_test(self):
self.test_validateaddress()
self.test_getaddressinfo()
if __name__ == '__main__':
InvalidAddressErrorMessageTest().main() |
|
ACK 28b3a32 |
|
cherry-pick-only ACK 28b3a3206097b89c7cf5f510e83f6027324b51c8 did not review code nor test 👓 Show signature and timestampSignature: Timestamp of file with hash |
|
@jnewbery Added a commit that does that. |
|
Oops. Sorry. I think the linter is failing because of an unused import: diff --git a/test/functional/rpc_invalid_address_message.py b/test/functional/rpc_invalid_address_message.py
index 4626f62b0f..814f50c9e6 100755
--- a/test/functional/rpc_invalid_address_message.py
+++ b/test/functional/rpc_invalid_address_message.py
@@ -6,10 +6,7 @@
from test_framework.test_framework import BitcoinTestFramework
-from test_framework.util import (
- assert_equal,
- assert_raises_rpc_error,
-)
+from test_framework.util import assert_raises_rpc_error
BECH32_VALID = 'bcrt1qtmp74ayg7p24uslctssvjm06q5phz4yrxucgnv'
BECH32_INVALID_BECH32 = 'bcrt1p0xlxvlhemja6c4dqv22uapctqupfhlxm9h8z3k2e72q4k9hcz7vqdmchcc' |
ce14a52 to
66009fc
Compare
|
@jnewbery Thanks, fixed! |
Github-Pull: bitcoin#20861 Rebased-From: da2bb69
Github-Pull: bitcoin#20861 Rebased-From: 25b1c6e
This also includes updates to the Python test framework implementation, test vectors, and release notes. Github-Pull: bitcoin#20861 Rebased-From: fe5e495
Github-Pull: bitcoin#20861 Rebased-From: 2e7c80f
Github-Pull: bitcoin#20861 Rebased-From: 0334602
Reduced version of the test from master/bitcoin#20861 by John Newbery. Github-Pull: bitcoin#20861 Rebased-From: fe5e495
66009fc to
f2195d7
Compare
|
Updated to mention v0.21.1 in |
|
utACK f2195d7 Verified the range-diff. Only difference is the versions in bips.md and removing the unnecessary import in rpc_invalid_address_message.py. |
|
cherry-pick re-ACK f2195d7 , only change is version number in doc/bips and new test commit 🍝 Show signature and timestampSignature: Timestamp of file with hash |
Backport of #20861. Also includes #21471.