Skip to content

Commit

Permalink
Update blockbook and API to handle customization
Browse files Browse the repository at this point in the history
  • Loading branch information
Liquid369 committed Jul 8, 2024
1 parent 29d7758 commit 424ff14
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
7 changes: 4 additions & 3 deletions src/apiClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@ def process_api_exceptions_int(*args, **kwargs):

class ApiClient:

def __init__(self, isTestnet=False):
self.isTestnet = isTestnet
self.api = BlockBookClient(isTestnet)
def __init__(self, main_wnd):
self.main_wnd = main_wnd
self.isTestnet = main_wnd.isTestnetRPC
self.api = BlockBookClient(main_wnd, self.isTestnet)

@process_api_exceptions
def getAddressUtxos(self, address):
Expand Down
14 changes: 8 additions & 6 deletions src/blockbookClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,16 @@ def process_blockbook_exceptions_int(*args, **kwargs):


class BlockBookClient:

def __init__(self, isTestnet=False):
def __init__(self, main_wnd, isTestnet=False):
self.main_wnd = main_wnd
self.isTestnet = isTestnet
if isTestnet:
self.url = "https://testnet.rockdev.org/"
self.loadURL()

def loadURL(self):
if self.isTestnet:
self.url = self.main_wnd.getExplorerURL('testnet')
else:
self.url = "https://explorer.rockdev.org/"
self.url = self.main_wnd.getExplorerURL('mainnet')

def checkResponse(self, method, param=""):
url = self.url + "/api/%s" % method
Expand All @@ -53,7 +56,6 @@ def checkResponse(self, method, param=""):
@process_blockbook_exceptions
def getAddressUtxos(self, address):
utxos = self.checkResponse("utxo", address)
# Add script for cryptoID legacy
for u in utxos:
u["script"] = ""
return utxos
Expand Down

0 comments on commit 424ff14

Please sign in to comment.