commit 4737aa6c2a5a8afcb84bcb3fd523d7edc6ca4b22
parent 52acb7ab66d68da9ed5f6ceda58181abf1153825
Author: ghost43 <somber.night@protonmail.com>
Date: Fri, 2 Feb 2018 23:26:25 +0100
migrated some commands from addr to scripthash (#3826)
* migrated some commands from addr to scripthash
* remove getproof command
Diffstat:
1 file changed, 7 insertions(+), 13 deletions(-)
diff --git a/lib/commands.py b/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,21 +316,13 @@ 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
uses this to verify transactions (Simple Payment Verification)."""