-
Notifications
You must be signed in to change notification settings - Fork 109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
listunspent and import_addresses API methods #249
Open
lawlawlaw
wants to merge
8
commits into
chris-belcher:master
Choose a base branch
from
commerceblock:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
65600d1
Update README.md
lawlawlaw 7c7e632
Add listunspent method
lawlawlaw 4461635
Allow import of addresses and rescan via an API method.
lawlawlaw 2edecbc
Update README.md
lawlawlaw 8fac88d
Update README
lawlawlaw e9bc701
Revert subscribe_all_addresses log output.
lawlawlaw 4962377
Merge pull request #1 from commerceblock/listunspent
lawlawlaw 343ce3a
added dockerfile
tomt1664 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
FROM python | ||
WORKDIR / | ||
RUN git clone https://github.com/commerceblock/electrum-personal-server.git | ||
WORKDIR /electrum-personal-server | ||
ADD config.ini config.ini | ||
RUN pip3 install . | ||
CMD ["electrum-personal-server", "config.ini"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,11 +7,13 @@ | |
import tempfile | ||
import socket | ||
from collections import defaultdict | ||
from electrumpersonalserver.server.deterministicwallet import import_addresses | ||
|
||
from electrumpersonalserver.server.hashes import ( | ||
hash_merkle_root, | ||
get_status_electrum, | ||
bytes_fmt | ||
bytes_fmt, | ||
address_to_script | ||
) | ||
from .jsonrpc import JsonRpc, JsonRpcError | ||
from electrumpersonalserver.server.peertopeer import tor_broadcast_tx | ||
|
@@ -256,6 +258,14 @@ def handle_query(self, query): | |
+ "hash(address) = " + scrhash) | ||
raise UnknownScripthashError(scrhash) | ||
self._send_response(query, balance) | ||
elif method == "blockchain.scripthash.listunspent": | ||
scrhash = query["params"][0] | ||
utxos = self.txmonitor.get_address_utxos(scrhash) | ||
if utxos == None: | ||
self.logger.warning("Address history not known to server, " | ||
+ "hash(address) = " + scrhash) | ||
raise UnknownScripthashError(scrhash) | ||
self._send_response(query, utxos) | ||
elif method == "server.ping": | ||
self._send_response(query, None) | ||
elif method == "blockchain.headers.subscribe": | ||
|
@@ -384,6 +394,7 @@ def handle_query(self, query): | |
self._send_response(query, result) | ||
elif method == "blockchain.estimatefee": | ||
estimate = self.rpc.call("estimatesmartfee", [query["params"][0]]) | ||
self.logger.info('estimate: ' + estimate) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove from this PR please, it's irrelevant. Also I think it conflicts with another edit I made recently. |
||
feerate = 0.0001 | ||
if "feerate" in estimate: | ||
feerate = estimate["feerate"] | ||
|
@@ -475,7 +486,27 @@ def handle_query(self, query): | |
except JsonRpcError as e: | ||
error = {"message": repr(e)} | ||
self._send_error(query["id"], error) | ||
elif method == "import_addresses": | ||
addresses = query["params"][0] | ||
rescan_height = False | ||
if len(query["params"]) > 1: | ||
rescan_height = query["params"][1] | ||
if rescan_height < 0: | ||
rescan_height = False | ||
if len(addresses) > 0: | ||
spks_to_monitor = [] | ||
spks_to_monitor.extend([address_to_script(addr, self.rpc) for addr in addresses]) | ||
self.logger.info("Importing addresses:" + ' '.join(map(str,addresses)) + "...") | ||
import_addresses(self.rpc, spks_to_monitor, [], -1, self.logger) | ||
self.logger.info("end") | ||
if ( rescan_height ): | ||
self.logger.info("Rescanning. . . for progress indicator see the bitcoin node's" + " debug.log file") | ||
self.rpc.call("rescanblockchain", [rescan_height]) | ||
self.logger.info("end") | ||
self.txmonitor.build_address_history(spks_to_monitor) | ||
self._send_response(query, { "result": "success"} ) | ||
else: | ||
self.logger.error(method) | ||
self.logger.error("*** BUG! Not handling method: " + method | ||
+ " query=" + str(query)) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove these irrelevant line changes. Or if you want to refactor then open another PR for them.