mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-10-11 12:03:04 +02:00
[tests] move generate_wif_key to wallet_util.py
generate_wif_key is a wallet utility function. Move it from the EC key module to the wallet util module.
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
from collections import namedtuple
|
||||
|
||||
from test_framework.address import (
|
||||
byte_to_base58,
|
||||
key_to_p2pkh,
|
||||
key_to_p2sh_p2wpkh,
|
||||
key_to_p2wpkh,
|
||||
@@ -13,10 +14,7 @@ from test_framework.address import (
|
||||
script_to_p2sh_p2wsh,
|
||||
script_to_p2wsh,
|
||||
)
|
||||
from test_framework.key import (
|
||||
bytes_to_wif,
|
||||
ECKey,
|
||||
)
|
||||
from test_framework.key import ECKey
|
||||
from test_framework.script import (
|
||||
CScript,
|
||||
OP_0,
|
||||
@@ -120,3 +118,14 @@ def test_address(node, address, **kwargs):
|
||||
raise AssertionError("key {} unexpectedly returned in getaddressinfo.".format(key))
|
||||
elif addr_info[key] != value:
|
||||
raise AssertionError("key {} value {} did not match expected value {}".format(key, addr_info[key], value))
|
||||
|
||||
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)
|
||||
|
Reference in New Issue
Block a user