migrated some commands from addr to scripthash (#3826)
* migrated some commands from addr to scripthash * remove getproof command
This commit is contained in:
@@ -34,7 +34,7 @@ from functools import wraps
|
|||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
|
|
||||||
from .import util
|
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 .import bitcoin
|
||||||
from .bitcoin import is_address, hash_160, COIN, TYPE_ADDRESS
|
from .bitcoin import is_address, hash_160, COIN, TYPE_ADDRESS
|
||||||
from .i18n import _
|
from .i18n import _
|
||||||
@@ -175,7 +175,8 @@ class Commands:
|
|||||||
"""Return the transaction history of any address. Note: This is a
|
"""Return the transaction history of any address. Note: This is a
|
||||||
walletless server query, results are not checked by SPV.
|
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')
|
@command('w')
|
||||||
def listunspent(self):
|
def listunspent(self):
|
||||||
@@ -192,7 +193,8 @@ class Commands:
|
|||||||
"""Returns the UTXO list of any address. Note: This
|
"""Returns the UTXO list of any address. Note: This
|
||||||
is a walletless server query, results are not checked by SPV.
|
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('')
|
@command('')
|
||||||
def serialize(self, jsontx):
|
def serialize(self, jsontx):
|
||||||
@@ -314,20 +316,12 @@ class Commands:
|
|||||||
"""Return the balance of any address. Note: This is a walletless
|
"""Return the balance of any address. Note: This is a walletless
|
||||||
server query, results are not checked by SPV.
|
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["confirmed"] = str(Decimal(out["confirmed"])/COIN)
|
||||||
out["unconfirmed"] = str(Decimal(out["unconfirmed"])/COIN)
|
out["unconfirmed"] = str(Decimal(out["unconfirmed"])/COIN)
|
||||||
return out
|
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')
|
@command('n')
|
||||||
def getmerkle(self, txid, height):
|
def getmerkle(self, txid, height):
|
||||||
"""Get Merkle branch of a transaction included in a block. Electrum
|
"""Get Merkle branch of a transaction included in a block. Electrum
|
||||||
|
|||||||
Reference in New Issue
Block a user