mirror of
https://github.com/romanz/electrs.git
synced 2024-11-19 01:43:29 +01:00
Add address->scripthash conversion tool
This commit is contained in:
parent
5d7ad36525
commit
7d521f8fe8
31
contrib/script_hash.py
Executable file
31
contrib/script_hash.py
Executable file
@ -0,0 +1,31 @@
|
||||
#!/usr/bin/env python3
|
||||
import argparse
|
||||
import datetime
|
||||
import hashlib
|
||||
import io
|
||||
import sys
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('--network', default='mainnet')
|
||||
args = parser.parse_args()
|
||||
|
||||
if args.network == 'regtest':
|
||||
from pycoin.symbols.xrt import network
|
||||
elif args.network == 'testnet':
|
||||
from pycoin.symbols.xtn import network
|
||||
elif args.network == 'mainnet':
|
||||
from pycoin.symbols.btc import network
|
||||
else:
|
||||
raise ValueError(f"unknown network: {args.network}")
|
||||
|
||||
for line in sys.stdin:
|
||||
addr = line.strip()
|
||||
script = network.parse.address(addr).script()
|
||||
script_hash = hashlib.sha256(script).digest()
|
||||
print(script_hash[::-1].hex())
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
1
contrib/script_hash.sh
Symbolic link
1
contrib/script_hash.sh
Symbolic link
@ -0,0 +1 @@
|
||||
venv_wrapper.sh
|
Loading…
Reference in New Issue
Block a user