Browse Source
Update contrib/ scripts to use latest PyCoin
patch-3
Roman Zeyde
5 years ago
No known key found for this signature in database
GPG Key ID: 87CAE5FA46917CBB
2 changed files with
9 additions and
14 deletions
-
contrib/addr.py
-
contrib/xpub.py
|
|
@ -3,8 +3,6 @@ import hashlib |
|
|
|
import sys |
|
|
|
import argparse |
|
|
|
|
|
|
|
from pycoin.coins.bitcoin.networks import BitcoinTestnet, BitcoinMainnet |
|
|
|
|
|
|
|
import client |
|
|
|
|
|
|
|
def main(): |
|
|
@ -14,15 +12,15 @@ def main(): |
|
|
|
args = parser.parse_args() |
|
|
|
|
|
|
|
if args.testnet: |
|
|
|
Network = BitcoinTestnet |
|
|
|
port = 60001 |
|
|
|
from pycoin.symbols.xtn import network |
|
|
|
else: |
|
|
|
Network = BitcoinMainnet |
|
|
|
port = 50001 |
|
|
|
from pycoin.symbols.btc import network |
|
|
|
|
|
|
|
conn = client.Client(('localhost', port)) |
|
|
|
for addr in args.address: |
|
|
|
script = Network.ui.script_for_address(addr) |
|
|
|
script = network.parse.address(addr).script() |
|
|
|
script_hash = hashlib.sha256(script).digest()[::-1].hex() |
|
|
|
reply = conn.call('blockchain.scripthash.get_balance', script_hash) |
|
|
|
result = reply['result'] |
|
|
|
|
|
@ -4,26 +4,23 @@ import sys |
|
|
|
|
|
|
|
from logbook import Logger, StreamHandler |
|
|
|
|
|
|
|
from pycoin.coins.bitcoin.networks import BitcoinMainnet |
|
|
|
import pycoin.ui.key_from_text |
|
|
|
import pycoin.key |
|
|
|
from pycoin.symbols.btc import network |
|
|
|
|
|
|
|
import client |
|
|
|
|
|
|
|
script_for_address = BitcoinMainnet.ui.script_for_address |
|
|
|
|
|
|
|
log = Logger(__name__) |
|
|
|
log = Logger("xpub") |
|
|
|
|
|
|
|
def main(): |
|
|
|
conn = client.Client(('localhost', 50001)) |
|
|
|
xpub, = sys.argv[1:] |
|
|
|
total = 0 |
|
|
|
k = pycoin.ui.key_from_text.key_from_text(xpub) |
|
|
|
xpub = network.parse.bip32_pub(xpub) |
|
|
|
|
|
|
|
for change in (0, 1): |
|
|
|
empty = 0 |
|
|
|
for n in range(100): |
|
|
|
address = k.subkey(change).subkey(n).address() |
|
|
|
script = script_for_address(address) |
|
|
|
address = xpub.subkey(change).subkey(n).address() |
|
|
|
script = network.parse.address(address).script() |
|
|
|
script_hash = hashlib.sha256(script).digest()[::-1].hex() |
|
|
|
log.debug('{}', conn.call('blockchain.scripthash.get_history', |
|
|
|
script_hash)) |
|
|
|