Skip to content
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

Remove local caching #242

Merged
merged 7 commits into from
Jul 17, 2020
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
4 changes: 2 additions & 2 deletions src/cryptoadvance/specter/bitcoind.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from .helpers import which
from .server import DATA_FOLDER
from .rpc import RpcError
from .rpc_cache import BitcoinCLICached
from .rpc import BitcoinCLI
from .helpers import load_jsons

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -42,7 +42,7 @@ def ipaddress(self,ipaddress):
def get_cli(self):
''' returns a BitcoinCLI '''
# def __init__(self, user, passwd, host="127.0.0.1", port=8332, protocol="http", path="", timeout=30, **kwargs):
cli = BitcoinCLICached(self.rpcuser, self.rpcpassword, host=self.ipaddress, port=self.rpcport)
cli = BitcoinCLI(self.rpcuser, self.rpcpassword, host=self.ipaddress, port=self.rpcport)
cli.getblockchaininfo()
return cli

Expand Down
20 changes: 12 additions & 8 deletions src/cryptoadvance/specter/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -724,17 +724,24 @@ def wallet(wallet_alias):
@app.route('/wallets/<wallet_alias>/tx/')
@login_required
def wallet_tx(wallet_alias):
return redirect("/wallets/%s/tx/history" % wallet_alias)

@app.route('/wallets/<wallet_alias>/tx/history/')
@login_required
def wallet_tx_history(wallet_alias):
app.specter.check()
try:
wallet = app.specter.wallet_manager.get_by_alias(wallet_alias)
except SpecterError as se:
app.logger.error("SpecterError while wallet_tx: %s" % se)
return render_template("base.jinja", error=se, specter=app.specter, rand=rand)
return render_template("wallet/history/txs/wallet_tx.jinja", wallet_alias=wallet_alias, wallet=wallet, specter=app.specter, rand=rand)
idx = int(request.args.get('idx', default=0))

return render_template("wallet/history/txs/wallet_tx.jinja", idx=idx, wallet_alias=wallet_alias, wallet=wallet, history=True, specter=app.specter, rand=rand)

@app.route('/wallets/<wallet_alias>/addresses/', methods=['GET', 'POST'])
@app.route('/wallets/<wallet_alias>/tx/utxo/', methods=['GET', 'POST'])
@login_required
def wallet_addresses(wallet_alias):
def wallet_tx_utxo(wallet_alias):
app.specter.check()
try:
wallet = app.specter.wallet_manager.get_by_alias(wallet_alias)
Expand All @@ -753,8 +760,7 @@ def wallet_addresses(wallet_alias):
for address in wallet.addresses_on_label(account):
wallet.setlabel(address, label)
wallet.getdata()
alladdresses = True if request.args.get('all') != 'False' else False
return render_template("wallet/history/addresses/wallet_addresses.jinja", wallet_alias=wallet_alias, wallet=wallet, alladdresses=alladdresses, viewtype=viewtype, specter=app.specter, rand=rand)
return render_template("wallet/history/utxo/wallet_utxo.jinja", wallet_alias=wallet_alias, wallet=wallet, history=False, viewtype=viewtype, specter=app.specter, rand=rand)

@app.route('/wallets/<wallet_alias>/receive/', methods=['GET', 'POST'])
@login_required
Expand All @@ -772,7 +778,7 @@ def wallet_receive(wallet_alias):
elif action == "updatelabel":
label = request.form['label']
wallet.setlabel(wallet.address, label)
if wallet.tx_on_current_address > 0:
if wallet.is_current_address_used:
wallet.getnewaddress()
return render_template("wallet/receive/wallet_receive.jinja", wallet_alias=wallet_alias, wallet=wallet, specter=app.specter, rand=rand)

Expand Down Expand Up @@ -952,8 +958,6 @@ def wallet_settings(wallet_alias):
wallet.keypoolrefill(wallet.keypool, wallet.keypool + delta)
wallet.keypoolrefill(wallet.change_keypool, wallet.change_keypool + delta, change=True)
wallet.getdata()
elif action == "rebuildcache":
wallet.cli.cache.rebuild_cache()
elif action == "deletewallet":
app.specter.wallet_manager.delete_wallet(wallet)
response = redirect(url_for('index'))
Expand Down
233 changes: 0 additions & 233 deletions src/cryptoadvance/specter/corecache.py

This file was deleted.

19 changes: 19 additions & 0 deletions src/cryptoadvance/specter/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,3 +413,22 @@ def seed_to_hd_master_key(seed, testnet=False) -> str:

# Return base58
return b58encode(xprv)

# Transaction processing helpers

def parse_utxo(wallet, utxo):
for tx in utxo:
tx_data = wallet.cli.gettransaction(tx['txid'])
tx['time'] = tx_data['time']
if (len(tx_data['details']) > 1):
for details in tx_data['details']:
if details['category'] != 'send':
tx['category'] = details['category']
break
else:
tx['category'] = tx_data['details'][0]['category']
if 'confirmations' in tx_data:
tx['confirmations'] = tx_data['confirmations']
else:
tx['confirmations'] = 0
return utxo
Loading