-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathp2pkh.py
More file actions
executable file
·21 lines (17 loc) · 779 Bytes
/
p2pkh.py
File metadata and controls
executable file
·21 lines (17 loc) · 779 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/usr/bin/env python3
import argparse
from blockchain_fundamentals import *
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Generate P2PKH address from compressed public key')
parser.add_argument('pubkey', metavar='pubkey')
parser.add_argument('-m', '--mainnet', action='store_true', default=True)
parser.add_argument('-t', '--testnet', action='store_true')
parser.add_argument('-r', '--regtest', action='store_true')
args = parser.parse_args()
if args.mainnet:
address = ToP2PKH(args.pubkey, 'mainnet').decode('utf-8')
if args.testnet:
address = ToP2PKH(args.pubkey, 'testnet').decode('utf-8')
if args.regtest:
address = ToP2PKH(args.pubkey, 'regtest').decode('utf-8')
print(address)