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

Chore: upgrade flask and corresponding libs #1666

Merged
merged 7 commits into from
Apr 26, 2022
Merged
Show file tree
Hide file tree
Changes from 3 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
7 changes: 4 additions & 3 deletions requirements.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
certifi==2021.10.08
chardet==3.0.4
Click==7.1.2
Flask==1.1.4
Click==8.1.1
Flask==2.1.1
Werkzeug==2.0.0 # need to pin because Flask doesn't work with newer ones
Flask-Babel==2.0.0
Flask-Cors==3.0.10
Flask-Login==0.5.0
Expand All @@ -18,7 +19,7 @@ stem==1.8.0
embit==0.4.12
psutil==5.7.3
pyopenssl==20.0.1
flask_wtf==0.14.3
flask_wtf==0.15.1
pgpy==0.5.4
cbor==1.0.0
mnemonic==0.20
Expand Down
221 changes: 135 additions & 86 deletions requirements.txt

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions src/cryptoadvance/specter/managers/service_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,6 @@ def inject_stuff():
ext_prefix = app.config["EXT_URL_PREFIX"]

try:
app.register_blueprint(
clazz.blueprint, url_prefix=f"{ext_prefix}/{clazz.id}"
)
logger.info(f" Mounted {clazz.id} to {ext_prefix}/{clazz.id}")
if (
app.testing
and len([vf for vf in app.view_functions if vf.startswith(clazz.id)])
Expand All @@ -152,6 +148,11 @@ def inject_stuff():
app.register_blueprint(
clazz.blueprint, url_prefix=f"{ext_prefix}/{clazz.id}"
)
else:
app.register_blueprint(
clazz.blueprint, url_prefix=f"{ext_prefix}/{clazz.id}"
)
logger.info(f" Mounted {clazz.id} to {ext_prefix}/{clazz.id}")
except AssertionError as e:
if str(e).startswith("A name collision"):
raise SpecterError(
Expand Down
22 changes: 11 additions & 11 deletions src/cryptoadvance/specter/server_endpoints/filters.py
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
from datetime import datetime
from flask import current_app as app
from flask import Blueprint
from jinja2 import contextfilter
from jinja2 import pass_context
from ..helpers import to_ascii20

filters_bp = Blueprint("filters", __name__)

############### filters ##################


@contextfilter
@pass_context
@filters_bp.app_template_filter("ascii20")
def ascii20(context, name):
return to_ascii20(name)


@contextfilter
@pass_context
@filters_bp.app_template_filter("unique_len")
def unique_len(context, arr):
return len(set(arr))


@contextfilter
@pass_context
@filters_bp.app_template_filter("datetime")
def timedatetime(context, s):
return format(datetime.fromtimestamp(s), "%d.%m.%Y %H:%M")


@contextfilter
@pass_context
@filters_bp.app_template_filter("btcamount")
def btcamount(context, value):
if value is None:
Expand All @@ -38,14 +38,14 @@ def btcamount(context, value):
return "{:,.8f}".format(value).rstrip("0").rstrip(".")


@contextfilter
@pass_context
@filters_bp.app_template_filter("btc2sat")
def btc2sat(context, value):
value = int(round(float(value) * 1e8))
return f"{value}"


@contextfilter
@pass_context
@filters_bp.app_template_filter("feerate")
def feerate(context, value):
value = float(value) * 1e8
Expand All @@ -56,7 +56,7 @@ def feerate(context, value):
return "{:,.2f}".format(value).rstrip("0").rstrip(".")


@contextfilter
@pass_context
@filters_bp.app_template_filter("btcunitamount")
def btcunitamount(context, value):
if app.specter.hide_sensitive_info:
Expand All @@ -71,7 +71,7 @@ def btcunitamount(context, value):
return "{:,.0f}".format(round(value * 1e8))


@contextfilter
@pass_context
@filters_bp.app_template_filter("altunit")
def altunit(context, value):
if app.specter.hide_sensitive_info:
Expand All @@ -93,14 +93,14 @@ def altunit(context, value):
return ""


@contextfilter
@pass_context
@filters_bp.app_template_filter("bytessize")
def bytessize(context, value):
value = float(value)
return "{:,.0f}".format(value / float(1 << 30)) + " GB"


@contextfilter
@pass_context
@filters_bp.app_template_filter("assetlabel")
def assetlabel(context, asset):
if app.specter.hide_sensitive_info:
Expand Down
17 changes: 11 additions & 6 deletions src/cryptoadvance/specter/templates/includes/tx-table.html
Original file line number Diff line number Diff line change
Expand Up @@ -1003,12 +1003,17 @@ <h1>{{ _("Export transactions to CSV") }}</h1>
txRow.addEventListener('txRowSelected', (e) => {
let selectedRow = e.target;
if (e.detail.selected) {
this.selectedRows.push({
txid: e.detail.txid,
vout: e.detail.vout,
amount: e.detail.amount.toFixed(8),
locked: e.detail.locked,
});
// For some unknown reason, the event is triggered twice, so we have this workaround
k9ert marked this conversation as resolved.
Show resolved Hide resolved
// checking whether it has been added
if (this.selectedRows.filter(t => t.txid == e.detail.txid).length == 0) {
console.log("Adding ...")
this.selectedRows.push({
txid: e.detail.txid,
vout: e.detail.vout,
amount: e.detail.amount.toFixed(8),
locked: e.detail.locked,
});
}
} else {
// Remove unselected rows from array
this.selectedRows = this.selectedRows.filter(row => !(row.txid === e.detail.txid && row.vout === e.detail.vout))
Expand Down
6 changes: 6 additions & 0 deletions src/cryptoadvance/specter/wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -970,7 +970,10 @@ def delete_pending_psbt(self, txid, save=True):

def toggle_freeze_utxo(self, utxo_list):
# utxo = ["txid:vout", "txid:vout"]
utxo_list_done = [] # Preventing Duplicates server-side
for utxo in utxo_list:
if utxo in utxo_list_done:
continue
if utxo in self.frozen_utxo:
try:
self.rpc.lockunspent(
Expand All @@ -981,6 +984,7 @@ def toggle_freeze_utxo(self, utxo_list):
# UTXO was spent
print(e)
pass
logger.info(f"Unfreeze {utxo}")
self.frozen_utxo.remove(utxo)
else:
try:
Expand All @@ -992,7 +996,9 @@ def toggle_freeze_utxo(self, utxo_list):
# UTXO was spent
print(e)
pass
logger.info(f"Freeze {utxo}")
self.frozen_utxo.append(utxo)
utxo_list_done.append(utxo)

self.save_to_file()

Expand Down