Browse Source

migrated some commands from addr to scripthash (#3826)

* migrated some commands from addr to scripthash

* remove getproof command
3.1
ghost43 7 years ago
committed by GitHub
parent
commit
4737aa6c2a
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 20
      lib/commands.py

20
lib/commands.py

@ -34,7 +34,7 @@ from functools import wraps
from decimal import Decimal
from .import util
from .util import bfh, bh2u, format_satoshis, json_decode
from .util import bfh, bh2u, format_satoshis, json_decode, print_error
from .import bitcoin
from .bitcoin import is_address, hash_160, COIN, TYPE_ADDRESS
from .i18n import _
@ -175,7 +175,8 @@ class Commands:
"""Return the transaction history of any address. Note: This is a
walletless server query, results are not checked by SPV.
"""
return self.network.synchronous_get(('blockchain.address.get_history', [address]))
sh = bitcoin.address_to_scripthash(address)
return self.network.synchronous_get(('blockchain.scripthash.get_history', [sh]))
@command('w')
def listunspent(self):
@ -192,7 +193,8 @@ class Commands:
"""Returns the UTXO list of any address. Note: This
is a walletless server query, results are not checked by SPV.
"""
return self.network.synchronous_get(('blockchain.address.listunspent', [address]))
sh = bitcoin.address_to_scripthash(address)
return self.network.synchronous_get(('blockchain.scripthash.listunspent', [sh]))
@command('')
def serialize(self, jsontx):
@ -314,20 +316,12 @@ class Commands:
"""Return the balance of any address. Note: This is a walletless
server query, results are not checked by SPV.
"""
out = self.network.synchronous_get(('blockchain.address.get_balance', [address]))
sh = bitcoin.address_to_scripthash(address)
out = self.network.synchronous_get(('blockchain.scripthash.get_balance', [sh]))
out["confirmed"] = str(Decimal(out["confirmed"])/COIN)
out["unconfirmed"] = str(Decimal(out["unconfirmed"])/COIN)
return out
@command('n')
def getproof(self, address):
"""Get Merkle branch of an address in the UTXO set"""
p = self.network.synchronous_get(('blockchain.address.get_proof', [address]))
out = []
for i,s in p:
out.append(i)
return out
@command('n')
def getmerkle(self, txid, height):
"""Get Merkle branch of a transaction included in a block. Electrum

Loading…
Cancel
Save