Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

This is a electrum-adapter. It exposes a Bitcoin-Core style API while using an electron API in the backend. It might be useful in specific usecases, e.g. having better performance when connecting to a electrum-server via Tor. In order to do that, it needs a Database. Quite easily you can use a kind of builtin SQLite. Depending on your usecase, you might want to use an external DB.

Note! Requires embit from master branch. (Still true?!)
## Modes of usage

This can be used either in standalone mode or as a specter-extension. The second option is probably the main use-case.
Expand Down Expand Up @@ -56,4 +55,4 @@ Before your create a PR, make sure to [blackify](https://github.com/psf/black) a
there is a git [pre-commit hook](https://ljvmiranda921.github.io/notebook/2018/06/21/precommits-using-black-and-flake8/) which you can simply install like this:
```
pre-commit install
```
```
41 changes: 40 additions & 1 deletion src/cryptoadvance/spectrum/spectrum.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,6 @@ def sync_script(self, script, state=None):
) # not existing, how can we fix that?
# new tx
else:

tx_details = {
"tx_hash": tx_magic,
"blockhash": blockheader.get("blockhash"),
Expand Down Expand Up @@ -844,6 +843,46 @@ def getrawchangeaddress(self, wallet, address_type=None):
# TODO: refill keypool, subscribe
return desc.getscriptpubkey().address(self.network)

@walletrpc
def getaddressinfo(self, wallet, address: str):
ismine = False
ischange = False
iswatchonly = False
scriptpubkey = EmbitScript.from_address(address)
sc = Script.query.filter_by(
script=scriptpubkey.data.hex(), wallet=wallet
).first()
if sc:
ismine = sc.index is not None
if ismine:
ischange = sc.descriptor.internal
iswatchonly = sc.descriptor.private_descriptor is None
obj = {
"address": address,
"scriptPubKey": scriptpubkey.data.hex(),
"ismine": ismine,
"ischange": ischange,
"solvable": ismine,
"iswatchonly": iswatchonly,
}
if ismine:
desc = sc.descriptor.get_descriptor()
derived_desc = desc.derive(sc.index).to_public()
# convert xpubs to pubs
for k in derived_desc.keys:
if k.is_extended:
k.key = k.key.key
obj.update(
{
"desc": add_checksum(str(derived_desc)),
"parent_desc": add_checksum(str(desc.to_public())),
}
)
obj["labels"] = []
if sc and sc.label:
obj["labels"] = [sc.label]
return obj

@walletrpc
def listlabels(self, wallet, purpose=None):
return list(
Expand Down