aboutsummaryrefslogtreecommitdiff
path: root/test/functional/test_framework/key.py
diff options
context:
space:
mode:
authorAndrew Chow <achow101-github@achow101.com>2019-07-16 15:33:35 -0400
committerAndrew Chow <achow101-github@achow101.com>2020-04-23 13:59:48 -0400
commit223588b1bbc63dc57098bbd0baa48635e0cc0b82 (patch)
tree8e4d450e70699c56a5c9c1547a30f5022e62bba8 /test/functional/test_framework/key.py
parent869f7ab30aeb4d7fbd563c535b55467a8a0430cf (diff)
Add a --descriptors option to various tests
Adds a --descriptors option globally to the test framework. This will make the test create and use descriptor wallets. However some tests may not work with this. Some tests are modified to work with --descriptors and run with that option in test_runer: * wallet_basic.py * wallet_encryption.py * wallet_keypool.py * wallet_keypool_topup.py * wallet_labels.py * wallet_avoidreuse.py
Diffstat (limited to 'test/functional/test_framework/key.py')
-rw-r--r--test/functional/test_framework/key.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/test/functional/test_framework/key.py b/test/functional/test_framework/key.py
index 912c0ca978..f2d6fba4a6 100644
--- a/test/functional/test_framework/key.py
+++ b/test/functional/test_framework/key.py
@@ -8,6 +8,8 @@ keys, and is trivially vulnerable to side channel attacks. Do not use for
anything but tests."""
import random
+from .address import byte_to_base58
+
def modinv(a, n):
"""Compute the modular inverse of a modulo n
@@ -384,3 +386,14 @@ class ECKey():
rb = r.to_bytes((r.bit_length() + 8) // 8, 'big')
sb = s.to_bytes((s.bit_length() + 8) // 8, 'big')
return b'\x30' + bytes([4 + len(rb) + len(sb), 2, len(rb)]) + rb + bytes([2, len(sb)]) + sb
+
+def bytes_to_wif(b, compressed=True):
+ if compressed:
+ b += b'\x01'
+ return byte_to_base58(b, 239)
+
+def generate_wif_key():
+ # Makes a WIF privkey for imports
+ k = ECKey()
+ k.generate()
+ return bytes_to_wif(k.get_bytes(), k.is_compressed)