mmgen-tool: new privhex2pair subcommand
This commit is contained in:
parent
46f3f4884d
commit
1aff3980ee
2 changed files with 9 additions and 4 deletions
|
|
@ -118,6 +118,7 @@ mods = {
|
|||
'pubhash2addr',
|
||||
'pubhex2addr',
|
||||
'pubhex2redeem_script',
|
||||
'privhex2pair',
|
||||
'randpair',
|
||||
'randwif',
|
||||
'redeem_script2addr',
|
||||
|
|
|
|||
|
|
@ -58,19 +58,23 @@ class tool_cmd(tool_cmd_base):
|
|||
pubkey_type = self.mmtype.pubkey_type,
|
||||
compressed = self.mmtype.compressed).wif
|
||||
|
||||
def randpair(self):
|
||||
"generate a random private key/address pair"
|
||||
def privhex2pair(self, privhex: 'sstr'):
|
||||
"generate a wifkey/address pair from the provided hexadecimal key"
|
||||
gd = self._init_generators()
|
||||
from ..crypto import Crypto
|
||||
privkey = PrivKey(
|
||||
self.proto,
|
||||
Crypto(self.cfg).get_random(32),
|
||||
bytes.fromhex(privhex),
|
||||
pubkey_type = self.mmtype.pubkey_type,
|
||||
compressed = self.mmtype.compressed)
|
||||
return (
|
||||
privkey.wif,
|
||||
gd.ag.to_addr(gd.kg.gen_data(privkey)))
|
||||
|
||||
def randpair(self):
|
||||
"generate a random wifkey/address pair"
|
||||
from ..crypto import Crypto
|
||||
return self.privhex2pair(Crypto(self.cfg).get_random(32).hex())
|
||||
|
||||
def wif2hex(self, wifkey: 'sstr'):
|
||||
"convert a private key from WIF to hexadecimal format"
|
||||
return PrivKey(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue