mirror of
https://github.com/Retropex/bitcoin.git
synced 2025-05-29 13:32:33 +02:00
Merge branch 'qa_tfw_generate_keypair-21' into fix_pkg_eval_sigops_pr28471-25+knots
This commit is contained in:
commit
9d58bf6a27
@ -119,3 +119,15 @@ def generate_wif_key():
|
||||
k = ECKey()
|
||||
k.generate()
|
||||
return bytes_to_wif(k.get_bytes(), k.is_compressed)
|
||||
|
||||
def generate_keypair(compressed=True, wif=False):
|
||||
"""Generate a new random keypair and return the corresponding ECKey /
|
||||
bytes objects. The private key can also be provided as WIF (wallet
|
||||
import format) string instead, which is often useful for wallet RPC
|
||||
interaction."""
|
||||
privkey = ECKey()
|
||||
privkey.generate(compressed)
|
||||
pubkey = privkey.get_pubkey().get_bytes()
|
||||
if wif:
|
||||
privkey = bytes_to_wif(privkey.get_bytes(), compressed)
|
||||
return privkey, pubkey
|
||||
|
Loading…
Reference in New Issue
Block a user