aboutsummaryrefslogtreecommitdiff
path: root/test/functional/test_framework/segwit_addr.py
diff options
context:
space:
mode:
authorJohn Newbery <john@johnnewbery.com>2020-06-11 13:45:31 -0400
committerJohn Newbery <john@johnnewbery.com>2020-09-03 16:47:49 +0100
commit011e784f74411bd5d5dbccfd3af39e0937fd8933 (patch)
treeaf8ff1af13d22e8f619d260bea9d6d0aae2e29e6 /test/functional/test_framework/segwit_addr.py
parente4557133f595f357df5e16ae4f2f19c579631396 (diff)
downloadbitcoin-011e784f74411bd5d5dbccfd3af39e0937fd8933.tar.xz
[tests] Rename segwit encode and decode functions
These functions can be exported to other modules, so be explicit that they're encoding and decoding segwit addresses
Diffstat (limited to 'test/functional/test_framework/segwit_addr.py')
-rw-r--r--test/functional/test_framework/segwit_addr.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/test/functional/test_framework/segwit_addr.py b/test/functional/test_framework/segwit_addr.py
index 10d20eeda7..00c0d8a919 100644
--- a/test/functional/test_framework/segwit_addr.py
+++ b/test/functional/test_framework/segwit_addr.py
@@ -84,7 +84,7 @@ def convertbits(data, frombits, tobits, pad=True):
return ret
-def decode(hrp, addr):
+def decode_segwit_address(hrp, addr):
"""Decode a segwit address."""
hrpgot, data = bech32_decode(addr)
if hrpgot != hrp:
@@ -99,10 +99,10 @@ def decode(hrp, addr):
return (data[0], decoded)
-def encode(hrp, witver, witprog):
+def encode_segwit_address(hrp, witver, witprog):
"""Encode a segwit address."""
ret = bech32_encode(hrp, [witver] + convertbits(witprog, 8, 5))
- if decode(hrp, ret) == (None, None):
+ if decode_segwit_address(hrp, ret) == (None, None):
return None
return ret
@@ -111,8 +111,8 @@ class TestFrameworkScript(unittest.TestCase):
def test_python_bech32(addr):
hrp = addr[:4]
self.assertEqual(hrp, "bcrt")
- (witver, witprog) = decode(hrp, addr)
- self.assertEqual(encode(hrp, witver, witprog), addr)
+ (witver, witprog) = decode_segwit_address(hrp, addr)
+ self.assertEqual(encode_segwit_address(hrp, witver, witprog), addr)
# P2WPKH
test_python_bech32('bcrt1qthmht0k2qnh3wy7336z05lu2km7emzfpm3wg46')