Merge remote-tracking branch 'blackcoffeexbt/gerty' into gerty
This commit is contained in:
commit
061e9a1812
6 changed files with 175 additions and 101 deletions
|
|
@ -15,19 +15,21 @@ async def create_gerty(wallet_id: str, data: Gerty) -> Gerty:
|
||||||
name,
|
name,
|
||||||
wallet,
|
wallet,
|
||||||
utc_offset,
|
utc_offset,
|
||||||
|
type,
|
||||||
lnbits_wallets,
|
lnbits_wallets,
|
||||||
mempool_endpoint,
|
mempool_endpoint,
|
||||||
exchange,
|
exchange,
|
||||||
display_preferences,
|
display_preferences,
|
||||||
refresh_time
|
refresh_time
|
||||||
)
|
)
|
||||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||||
""",
|
""",
|
||||||
(
|
(
|
||||||
gerty_id,
|
gerty_id,
|
||||||
data.name,
|
data.name,
|
||||||
data.wallet,
|
data.wallet,
|
||||||
data.utc_offset,
|
data.utc_offset,
|
||||||
|
data.type,
|
||||||
data.lnbits_wallets,
|
data.lnbits_wallets,
|
||||||
data.mempool_endpoint,
|
data.mempool_endpoint,
|
||||||
data.exchange,
|
data.exchange,
|
||||||
|
|
|
||||||
|
|
@ -7,13 +7,13 @@ from loguru import logger
|
||||||
from .number_prefixer import *
|
from .number_prefixer import *
|
||||||
|
|
||||||
|
|
||||||
def get_percent_difference(current, previous, precision=4):
|
def get_percent_difference(current, previous, precision=3):
|
||||||
difference = (current - previous) / current * 100
|
difference = (current - previous) / current * 100
|
||||||
return "{0}{1}%".format("+" if difference > 0 else "", round(difference, precision))
|
return "{0}{1}%".format("+" if difference > 0 else "", round(difference, precision))
|
||||||
|
|
||||||
|
|
||||||
# A helper function get a nicely formated dict for the text
|
# A helper function get a nicely formated dict for the text
|
||||||
def get_text_item_dict(text: str, font_size: int, x_pos: int = None, y_pos: int = None):
|
def get_text_item_dict(text: str, font_size: int, x_pos: int = None, y_pos: int = None, gerty_type: str = 'Gerty'):
|
||||||
# Get line size by font size
|
# Get line size by font size
|
||||||
line_width = 20
|
line_width = 20
|
||||||
if font_size <= 12:
|
if font_size <= 12:
|
||||||
|
|
@ -25,6 +25,21 @@ def get_text_item_dict(text: str, font_size: int, x_pos: int = None, y_pos: int
|
||||||
elif font_size <= 40:
|
elif font_size <= 40:
|
||||||
line_width = 25
|
line_width = 25
|
||||||
|
|
||||||
|
# Get font sizes for Gerty mini
|
||||||
|
if(gerty_type.lower() == 'mini gerty'):
|
||||||
|
if font_size <= 12:
|
||||||
|
font_size = 1
|
||||||
|
if font_size <= 15:
|
||||||
|
font_size = 1
|
||||||
|
elif font_size <= 20:
|
||||||
|
font_size = 2
|
||||||
|
elif font_size <= 40:
|
||||||
|
font_size = 2
|
||||||
|
else:
|
||||||
|
font_size = 5
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# wrap the text
|
# wrap the text
|
||||||
wrapper = textwrap.TextWrapper(width=line_width)
|
wrapper = textwrap.TextWrapper(width=line_width)
|
||||||
word_list = wrapper.wrap(text=text)
|
word_list = wrapper.wrap(text=text)
|
||||||
|
|
@ -68,18 +83,18 @@ async def get_mining_dashboard(gerty):
|
||||||
hashrateOneWeekAgo = data["hashrates"][6]["avgHashrate"]
|
hashrateOneWeekAgo = data["hashrates"][6]["avgHashrate"]
|
||||||
|
|
||||||
text = []
|
text = []
|
||||||
text.append(get_text_item_dict("Current mining hashrate", 12))
|
text.append(get_text_item_dict(text="Current mining hashrate", font_size=12,gerty_type=gerty.type))
|
||||||
text.append(
|
text.append(
|
||||||
get_text_item_dict(
|
get_text_item_dict(
|
||||||
"{0}hash".format(si_format(hashrateNow, 6, True, " ")), 20
|
text="{0}hash".format(si_format(hashrateNow, 6, True, " ")), font_size=20,gerty_type=gerty.type
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
text.append(
|
text.append(
|
||||||
get_text_item_dict(
|
get_text_item_dict(
|
||||||
"{0} vs 7 days ago".format(
|
text="{0} vs 7 days ago".format(
|
||||||
get_percent_difference(hashrateNow, hashrateOneWeekAgo, 3)
|
get_percent_difference(hashrateNow, hashrateOneWeekAgo, 3)
|
||||||
),
|
),
|
||||||
12,
|
font_size=12,gerty_type=gerty.type
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
areas.append(text)
|
areas.append(text)
|
||||||
|
|
@ -91,27 +106,27 @@ async def get_mining_dashboard(gerty):
|
||||||
# timeAvg
|
# timeAvg
|
||||||
text = []
|
text = []
|
||||||
progress = "{0}%".format(round(r.json()["progressPercent"], 2))
|
progress = "{0}%".format(round(r.json()["progressPercent"], 2))
|
||||||
text.append(get_text_item_dict("Progress through current epoch", 12))
|
text.append(get_text_item_dict(text="Progress through current epoch", font_size=12,gerty_type=gerty.type))
|
||||||
text.append(get_text_item_dict(progress, 60))
|
text.append(get_text_item_dict(text=progress, font_size=60,gerty_type=gerty.type))
|
||||||
areas.append(text)
|
areas.append(text)
|
||||||
|
|
||||||
# difficulty adjustment
|
# difficulty adjustment
|
||||||
text = []
|
text = []
|
||||||
stat = r.json()["remainingTime"]
|
stat = r.json()["remainingTime"]
|
||||||
text.append(get_text_item_dict("Time to next difficulty adjustment", 12))
|
text.append(get_text_item_dict(text="Time to next difficulty adjustment", font_size=12,gerty_type=gerty.type))
|
||||||
text.append(get_text_item_dict(get_time_remaining(stat / 1000, 3), 12))
|
text.append(get_text_item_dict(text=get_time_remaining(stat / 1000, 3), font_size=12,gerty_type=gerty.type))
|
||||||
areas.append(text)
|
areas.append(text)
|
||||||
|
|
||||||
# difficultyChange
|
# difficultyChange
|
||||||
text = []
|
text = []
|
||||||
difficultyChange = round(r.json()["difficultyChange"], 2)
|
difficultyChange = round(r.json()["difficultyChange"], 2)
|
||||||
text.append(get_text_item_dict("Estimated difficulty change", 12))
|
text.append(get_text_item_dict(text="Estimated difficulty change", font_size=12,gerty_type=gerty.type))
|
||||||
text.append(
|
text.append(
|
||||||
get_text_item_dict(
|
get_text_item_dict(
|
||||||
"{0}{1}%".format(
|
text="{0}{1}%".format(
|
||||||
"+" if difficultyChange > 0 else "", round(difficultyChange, 2)
|
"+" if difficultyChange > 0 else "", round(difficultyChange, 2)
|
||||||
),
|
),
|
||||||
60,
|
font_size=60,gerty_type=gerty.type
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
areas.append(text)
|
areas.append(text)
|
||||||
|
|
@ -142,49 +157,49 @@ async def get_lightning_stats(gerty):
|
||||||
areas = []
|
areas = []
|
||||||
|
|
||||||
text = []
|
text = []
|
||||||
text.append(get_text_item_dict("Channel Count", 12))
|
text.append(get_text_item_dict(text="Channel Count", font_size=12, gerty_type=gerty.type))
|
||||||
text.append(get_text_item_dict(format_number(data["latest"]["channel_count"]), 20))
|
text.append(get_text_item_dict(text=format_number(data["latest"]["channel_count"]), font_size=20, gerty_type=gerty.type))
|
||||||
difference = get_percent_difference(
|
difference = get_percent_difference(
|
||||||
current=data["latest"]["channel_count"],
|
current=data["latest"]["channel_count"],
|
||||||
previous=data["previous"]["channel_count"],
|
previous=data["previous"]["channel_count"],
|
||||||
)
|
)
|
||||||
text.append(get_text_item_dict("{0} in last 7 days".format(difference), 12))
|
text.append(get_text_item_dict(text="{0} in last 7 days".format(difference), font_size=12, gerty_type=gerty.type))
|
||||||
areas.append(text)
|
areas.append(text)
|
||||||
|
|
||||||
text = []
|
text = []
|
||||||
text.append(get_text_item_dict("Number of Nodes", 12))
|
text.append(get_text_item_dict(text="Number of Nodes", font_size=12,gerty_type=gerty.type))
|
||||||
text.append(get_text_item_dict(format_number(data["latest"]["node_count"]), 20))
|
text.append(get_text_item_dict(text=format_number(data["latest"]["node_count"]), font_size=20,gerty_type=gerty.type))
|
||||||
difference = get_percent_difference(
|
difference = get_percent_difference(
|
||||||
current=data["latest"]["node_count"], previous=data["previous"]["node_count"]
|
current=data["latest"]["node_count"], previous=data["previous"]["node_count"]
|
||||||
)
|
)
|
||||||
text.append(get_text_item_dict("{0} in last 7 days".format(difference), 12))
|
text.append(get_text_item_dict(text="{0} in last 7 days".format(difference), font_size=12,gerty_type=gerty.type))
|
||||||
areas.append(text)
|
areas.append(text)
|
||||||
|
|
||||||
text = []
|
text = []
|
||||||
text.append(get_text_item_dict("Total Capacity", 12))
|
text.append(get_text_item_dict(text="Total Capacity", font_size=12,gerty_type=gerty.type))
|
||||||
avg_capacity = float(data["latest"]["total_capacity"]) / float(100000000)
|
avg_capacity = float(data["latest"]["total_capacity"]) / float(100000000)
|
||||||
text.append(
|
text.append(
|
||||||
get_text_item_dict("{0} BTC".format(format_number(avg_capacity, 2)), 20)
|
get_text_item_dict(text="{0} BTC".format(format_number(avg_capacity, 2)), font_size=20,gerty_type=gerty.type)
|
||||||
)
|
)
|
||||||
difference = get_percent_difference(
|
difference = get_percent_difference(
|
||||||
current=data["latest"]["total_capacity"],
|
current=data["latest"]["total_capacity"],
|
||||||
previous=data["previous"]["total_capacity"],
|
previous=data["previous"]["total_capacity"],
|
||||||
)
|
)
|
||||||
text.append(get_text_item_dict("{0} in last 7 days".format(difference), 12))
|
text.append(get_text_item_dict(text="{0} in last 7 days".format(difference), font_size=12,gerty_type=gerty.type))
|
||||||
areas.append(text)
|
areas.append(text)
|
||||||
|
|
||||||
text = []
|
text = []
|
||||||
text.append(get_text_item_dict("Average Channel Capacity", 12))
|
text.append(get_text_item_dict(text="Average Channel Capacity", font_size=12,gerty_type=gerty.type))
|
||||||
text.append(
|
text.append(
|
||||||
get_text_item_dict(
|
get_text_item_dict(
|
||||||
"{0} sats".format(format_number(data["latest"]["avg_capacity"])), 20
|
text="{0} sats".format(format_number(data["latest"]["avg_capacity"])), font_size=20,gerty_type=gerty.type
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
difference = get_percent_difference(
|
difference = get_percent_difference(
|
||||||
current=data["latest"]["avg_capacity"],
|
current=data["latest"]["avg_capacity"],
|
||||||
previous=data["previous"]["avg_capacity"],
|
previous=data["previous"]["avg_capacity"],
|
||||||
)
|
)
|
||||||
text.append(get_text_item_dict("{0} in last 7 days".format(difference), 12))
|
text.append(get_text_item_dict(text="{0} in last 7 days".format(difference), font_size=12, gerty_type=gerty.type))
|
||||||
areas.append(text)
|
areas.append(text)
|
||||||
|
|
||||||
return areas
|
return areas
|
||||||
|
|
@ -247,17 +262,17 @@ async def get_mining_stat(stat_slug: str, gerty):
|
||||||
stat = await api_get_mining_stat(stat_slug, gerty)
|
stat = await api_get_mining_stat(stat_slug, gerty)
|
||||||
logger.debug(stat)
|
logger.debug(stat)
|
||||||
current = "{0}hash".format(si_format(stat['current'], 6, True, " "))
|
current = "{0}hash".format(si_format(stat['current'], 6, True, " "))
|
||||||
text.append(get_text_item_dict("Current Mining Hashrate", 20))
|
text.append(get_text_item_dict(text="Current Mining Hashrate", font_size=20,gerty_type=gerty.type))
|
||||||
text.append(get_text_item_dict(current, 40))
|
text.append(get_text_item_dict(text=current, font_size=40,gerty_type=gerty.type))
|
||||||
# compare vs previous time period
|
# compare vs previous time period
|
||||||
difference = get_percent_difference(current=stat['current'], previous=stat['1w'])
|
difference = get_percent_difference(current=stat['current'], previous=stat['1w'])
|
||||||
text.append(get_text_item_dict("{0} in last 7 days".format(difference), 12))
|
text.append(get_text_item_dict(text="{0} in last 7 days".format(difference), font_size=12,gerty_type=gerty.type))
|
||||||
elif stat_slug == "mining_current_difficulty":
|
elif stat_slug == "mining_current_difficulty":
|
||||||
stat = await api_get_mining_stat(stat_slug, gerty)
|
stat = await api_get_mining_stat(stat_slug, gerty)
|
||||||
text.append(get_text_item_dict("Current Mining Difficulty", 20))
|
text.append(get_text_item_dict(text="Current Mining Difficulty", font_size=20,gerty_type=gerty.type))
|
||||||
text.append(get_text_item_dict(format_number(stat['current']), 40))
|
text.append(get_text_item_dict(text=format_number(stat['current']), font_size=40,gerty_type=gerty.type))
|
||||||
difference = get_percent_difference(current=stat['current'], previous=stat['previous'])
|
difference = get_percent_difference(current=stat['current'], previous=stat['previous'])
|
||||||
text.append(get_text_item_dict("{0} since last adjustment".format(difference), 12))
|
text.append(get_text_item_dict(text="{0} since last adjustment".format(difference), font_size=12,gerty_type=gerty.type))
|
||||||
# text.append(get_text_item_dict("Required threshold for mining proof-of-work", 12))
|
# text.append(get_text_item_dict("Required threshold for mining proof-of-work", 12))
|
||||||
return text
|
return text
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,3 +23,9 @@ async def m002_add_utc_offset_col(db):
|
||||||
support for UTC offset
|
support for UTC offset
|
||||||
"""
|
"""
|
||||||
await db.execute("ALTER TABLE gerty.gertys ADD COLUMN utc_offset INT;")
|
await db.execute("ALTER TABLE gerty.gertys ADD COLUMN utc_offset INT;")
|
||||||
|
|
||||||
|
async def m003_add_gerty_model_col(db):
|
||||||
|
"""
|
||||||
|
support for Gerty model col
|
||||||
|
"""
|
||||||
|
await db.execute("ALTER TABLE gerty.gertys ADD COLUMN type TEXT;")
|
||||||
|
|
@ -11,6 +11,7 @@ class Gerty(BaseModel):
|
||||||
wallet: str
|
wallet: str
|
||||||
refresh_time: int = Query(None)
|
refresh_time: int = Query(None)
|
||||||
utc_offset: int = Query(None)
|
utc_offset: int = Query(None)
|
||||||
|
type: str
|
||||||
lnbits_wallets: str = Query(
|
lnbits_wallets: str = Query(
|
||||||
None
|
None
|
||||||
) # Wallets to keep an eye on, {"wallet-id": "wallet-read-key, etc"}
|
) # Wallets to keep an eye on, {"wallet-id": "wallet-read-key, etc"}
|
||||||
|
|
|
||||||
|
|
@ -127,6 +127,14 @@
|
||||||
label="Name"
|
label="Name"
|
||||||
placeholder="Son of Gerty"
|
placeholder="Son of Gerty"
|
||||||
></q-input>
|
></q-input>
|
||||||
|
<q-select
|
||||||
|
filled
|
||||||
|
dense
|
||||||
|
emit-value
|
||||||
|
v-model="formDialog.data.type"
|
||||||
|
:options="['Gerty', 'Mini Gerty']"
|
||||||
|
label="Gerty Type *"
|
||||||
|
></q-select>
|
||||||
<q-select
|
<q-select
|
||||||
filled
|
filled
|
||||||
dense
|
dense
|
||||||
|
|
@ -190,7 +198,9 @@
|
||||||
|
|
||||||
<p>Use the toggles below to control what your Gerty will display</p>
|
<p>Use the toggles below to control what your Gerty will display</p>
|
||||||
|
|
||||||
|
|
||||||
<q-expansion-item
|
<q-expansion-item
|
||||||
|
v-if="!isMiniGerty"
|
||||||
expand-separator
|
expand-separator
|
||||||
icon="grid_view"
|
icon="grid_view"
|
||||||
label="Dashboards"
|
label="Dashboards"
|
||||||
|
|
@ -200,17 +210,6 @@
|
||||||
label="LNbits Dashboard"
|
label="LNbits Dashboard"
|
||||||
></q-toggle>
|
></q-toggle>
|
||||||
|
|
||||||
<q-toggle
|
|
||||||
v-model="formDialog.data.display_preferences.fun_satoshi_quotes"
|
|
||||||
label="Satoshi Quotes"
|
|
||||||
>
|
|
||||||
<q-tooltip>Displays random quotes from Satoshi</q-tooltip>
|
|
||||||
</q-toggle>
|
|
||||||
<q-toggle
|
|
||||||
v-model="formDialog.data.display_preferences.fun_exchange_market_rate"
|
|
||||||
label="Fiat to BTC price"
|
|
||||||
></q-toggle>
|
|
||||||
|
|
||||||
<q-toggle
|
<q-toggle
|
||||||
v-model="formDialog.data.display_preferences.dashboard_onchain"
|
v-model="formDialog.data.display_preferences.dashboard_onchain"
|
||||||
label="Onchain Dashboard"
|
label="Onchain Dashboard"
|
||||||
|
|
@ -233,8 +232,20 @@
|
||||||
expand-separator
|
expand-separator
|
||||||
icon="pin"
|
icon="pin"
|
||||||
label="Single Data Points"
|
label="Single Data Points"
|
||||||
|
ref="single-data-points-expansion"
|
||||||
>
|
>
|
||||||
|
|
||||||
|
<q-toggle
|
||||||
|
v-model="formDialog.data.display_preferences.fun_exchange_market_rate"
|
||||||
|
label="Fiat to BTC price"
|
||||||
|
></q-toggle>
|
||||||
|
<q-toggle
|
||||||
|
v-if="!isMiniGerty"
|
||||||
|
v-model="formDialog.data.display_preferences.fun_satoshi_quotes"
|
||||||
|
label="Satoshi Quotes"
|
||||||
|
>
|
||||||
|
<q-tooltip>Displays random quotes from Satoshi</q-tooltip>
|
||||||
|
</q-toggle>
|
||||||
<q-expansion-item
|
<q-expansion-item
|
||||||
expand-separator
|
expand-separator
|
||||||
icon="perm_identity"
|
icon="perm_identity"
|
||||||
|
|
@ -279,6 +290,10 @@
|
||||||
v-model="formDialog.data.display_preferences.onchain_difficulty_epoch_time_remaining"
|
v-model="formDialog.data.display_preferences.onchain_difficulty_epoch_time_remaining"
|
||||||
label="Estimated time until next difficulty adjustment"
|
label="Estimated time until next difficulty adjustment"
|
||||||
></q-toggle>
|
></q-toggle>
|
||||||
|
<q-toggle
|
||||||
|
v-model="formDialog.data.display_preferences.onchain_block_height"
|
||||||
|
label="Current block height"
|
||||||
|
></q-toggle>
|
||||||
</q-expansion-item>
|
</q-expansion-item>
|
||||||
<q-expansion-item
|
<q-expansion-item
|
||||||
expand-separator
|
expand-separator
|
||||||
|
|
@ -295,6 +310,7 @@
|
||||||
|
|
||||||
<q-toggle
|
<q-toggle
|
||||||
v-model="formDialog.data.display_preferences.mempool_recommended_fees"
|
v-model="formDialog.data.display_preferences.mempool_recommended_fees"
|
||||||
|
v-if="!isMiniGerty"
|
||||||
label="Recommended fees"
|
label="Recommended fees"
|
||||||
></q-toggle>
|
></q-toggle>
|
||||||
|
|
||||||
|
|
@ -583,6 +599,7 @@
|
||||||
show: false,
|
show: false,
|
||||||
data: {
|
data: {
|
||||||
utc_offset: 0,
|
utc_offset: 0,
|
||||||
|
type: 'Gerty',
|
||||||
display_preferences: {
|
display_preferences: {
|
||||||
dashboard: true,
|
dashboard: true,
|
||||||
fun_satoshi_quotes: true,
|
fun_satoshi_quotes: true,
|
||||||
|
|
@ -596,6 +613,7 @@
|
||||||
onchain_difficulty_retarget_date: true,
|
onchain_difficulty_retarget_date: true,
|
||||||
onchain_difficulty_blocks_remaining: true,
|
onchain_difficulty_blocks_remaining: true,
|
||||||
onchain_difficulty_epoch_time_remaining: true,
|
onchain_difficulty_epoch_time_remaining: true,
|
||||||
|
onchain_block_height: true,
|
||||||
mempool_tx_count: true,
|
mempool_tx_count: true,
|
||||||
mining_current_hash_rate: true,
|
mining_current_hash_rate: true,
|
||||||
mining_current_difficulty: true,
|
mining_current_difficulty: true,
|
||||||
|
|
@ -619,6 +637,7 @@
|
||||||
lnbits_wallets: [],
|
lnbits_wallets: [],
|
||||||
mempool_endpoint: "https://mempool.space",
|
mempool_endpoint: "https://mempool.space",
|
||||||
refresh_time: 300,
|
refresh_time: 300,
|
||||||
|
type: 'Gerty',
|
||||||
display_preferences: {},
|
display_preferences: {},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -641,6 +660,7 @@
|
||||||
console.log('gerty.display_preferences', gerty.display_preferences)
|
console.log('gerty.display_preferences', gerty.display_preferences)
|
||||||
this.formDialog.data.id = gerty.id
|
this.formDialog.data.id = gerty.id
|
||||||
this.formDialog.data.name = gerty.name
|
this.formDialog.data.name = gerty.name
|
||||||
|
this.formDialog.data.type = gerty.type
|
||||||
this.formDialog.data.wallet = gerty.wallet
|
this.formDialog.data.wallet = gerty.wallet
|
||||||
this.formDialog.data.utc_offset = gerty.utc_offset
|
this.formDialog.data.utc_offset = gerty.utc_offset
|
||||||
this.formDialog.data.lnbits_wallets = JSON.parse(gerty.lnbits_wallets)
|
this.formDialog.data.lnbits_wallets = JSON.parse(gerty.lnbits_wallets)
|
||||||
|
|
@ -669,6 +689,7 @@
|
||||||
name: this.formDialog.data.name,
|
name: this.formDialog.data.name,
|
||||||
wallet: this.formDialog.data.wallet,
|
wallet: this.formDialog.data.wallet,
|
||||||
utc_offset: this.formDialog.data.utc_offset,
|
utc_offset: this.formDialog.data.utc_offset,
|
||||||
|
type: this.formDialog.data.type,
|
||||||
lnbits_wallets: JSON.stringify(this.formDialog.data.lnbits_wallets),
|
lnbits_wallets: JSON.stringify(this.formDialog.data.lnbits_wallets),
|
||||||
exchange: this.formDialog.data.exchange,
|
exchange: this.formDialog.data.exchange,
|
||||||
mempool_endpoint: this.formDialog.data.mempool_endpoint,
|
mempool_endpoint: this.formDialog.data.mempool_endpoint,
|
||||||
|
|
@ -697,6 +718,7 @@
|
||||||
updateGerty: function (wallet, data) {
|
updateGerty: function (wallet, data) {
|
||||||
var self = this
|
var self = this
|
||||||
data.utc_offset = this.formDialog.data.utc_offset
|
data.utc_offset = this.formDialog.data.utc_offset
|
||||||
|
data.type = this.formDialog.data.type
|
||||||
data.lnbits_wallets = JSON.stringify(this.formDialog.data.lnbits_wallets)
|
data.lnbits_wallets = JSON.stringify(this.formDialog.data.lnbits_wallets)
|
||||||
data.display_preferences = JSON.stringify(this.formDialog.data.display_preferences)
|
data.display_preferences = JSON.stringify(this.formDialog.data.display_preferences)
|
||||||
LNbits.api
|
LNbits.api
|
||||||
|
|
@ -744,12 +766,30 @@
|
||||||
LNbits.utils.exportCSV(this.gertysTable.columns, this.gertys)
|
LNbits.utils.exportCSV(this.gertysTable.columns, this.gertys)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
isMiniGerty() {
|
||||||
|
return (this.formDialog.data.type == 'Mini Gerty')
|
||||||
|
}
|
||||||
|
},
|
||||||
created: function () {
|
created: function () {
|
||||||
if (this.g.user.wallets.length) {
|
if (this.g.user.wallets.length) {
|
||||||
this.getGertys()
|
this.getGertys()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
|
'formDialog.data.type': {
|
||||||
|
handler(value) {
|
||||||
|
if (value == 'Mini Gerty') {
|
||||||
|
this.formDialog.data.display_preferences.dashboard = false;
|
||||||
|
this.formDialog.data.display_preferences.dashboard_onchain = false;
|
||||||
|
this.formDialog.data.display_preferences.dashboard_mining = false;
|
||||||
|
this.formDialog.data.display_preferences.lightning_dashboard = false;
|
||||||
|
this.formDialog.data.display_preferences.fun_satoshi_quotes = false;
|
||||||
|
this.formDialog.data.display_preferences.mempool_recommended_fees = false;
|
||||||
|
this.formDialog.data.display_preferences.onchain = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
toggleStates: {
|
toggleStates: {
|
||||||
handler(toggleStatesValue) {
|
handler(toggleStatesValue) {
|
||||||
// Switch all the toggles in each section to the relevant state
|
// Switch all the toggles in each section to the relevant state
|
||||||
|
|
|
||||||
|
|
@ -177,15 +177,20 @@ async def get_screen_data(screen_num: int, screens_list: dict, gerty):
|
||||||
wallets = await get_lnbits_wallet_balances(gerty)
|
wallets = await get_lnbits_wallet_balances(gerty)
|
||||||
text = []
|
text = []
|
||||||
for wallet in wallets:
|
for wallet in wallets:
|
||||||
text.append(get_text_item_dict("{0}'s Wallet".format(wallet['name']), 20))
|
text.append(get_text_item_dict(text="{0}'s Wallet".format(wallet['name']), font_size=20,gerty_type=gerty.type))
|
||||||
text.append(get_text_item_dict("{0} sats".format(format_number(wallet['balance'])), 40))
|
text.append(get_text_item_dict(text="{0} sats".format(format_number(wallet['balance'])), font_size=40,gerty_type=gerty.type))
|
||||||
areas.append(text)
|
areas.append(text)
|
||||||
elif screen_slug == "fun_satoshi_quotes":
|
elif screen_slug == "fun_satoshi_quotes":
|
||||||
areas.append(await get_satoshi_quotes())
|
areas.append(await get_satoshi_quotes(gerty))
|
||||||
elif screen_slug == "fun_exchange_market_rate":
|
elif screen_slug == "fun_exchange_market_rate":
|
||||||
areas.append(await get_exchange_rate(gerty))
|
areas.append(await get_exchange_rate(gerty))
|
||||||
elif screen_slug == "onchain_difficulty_epoch_progress":
|
elif screen_slug == "onchain_difficulty_epoch_progress":
|
||||||
areas.append(await get_onchain_stat(screen_slug, gerty))
|
areas.append(await get_onchain_stat(screen_slug, gerty))
|
||||||
|
elif screen_slug == "onchain_block_height":
|
||||||
|
logger.debug("iam block height")
|
||||||
|
text = []
|
||||||
|
text.append(get_text_item_dict(text=format_number(await get_block_height(gerty)), font_size=80, gerty_type=gerty.type))
|
||||||
|
areas.append(text)
|
||||||
elif screen_slug == "onchain_difficulty_retarget_date":
|
elif screen_slug == "onchain_difficulty_retarget_date":
|
||||||
areas.append(await get_onchain_stat(screen_slug, gerty))
|
areas.append(await get_onchain_stat(screen_slug, gerty))
|
||||||
elif screen_slug == "onchain_difficulty_blocks_remaining":
|
elif screen_slug == "onchain_difficulty_blocks_remaining":
|
||||||
|
|
@ -223,34 +228,34 @@ async def get_dashboard(gerty):
|
||||||
# XC rate
|
# XC rate
|
||||||
text = []
|
text = []
|
||||||
amount = await satoshis_amount_as_fiat(100000000, gerty.exchange)
|
amount = await satoshis_amount_as_fiat(100000000, gerty.exchange)
|
||||||
text.append(get_text_item_dict(format_number(amount), 40))
|
text.append(get_text_item_dict(text=format_number(amount), font_size=40,gerty_type=gerty.type))
|
||||||
text.append(get_text_item_dict("BTC{0} price".format(gerty.exchange), 15))
|
text.append(get_text_item_dict(text="BTC{0} price".format(gerty.exchange), font_size=15,gerty_type=gerty.type))
|
||||||
areas.append(text)
|
areas.append(text)
|
||||||
# balance
|
# balance
|
||||||
text = []
|
text = []
|
||||||
wallets = await get_lnbits_wallet_balances(gerty)
|
wallets = await get_lnbits_wallet_balances(gerty)
|
||||||
text = []
|
text = []
|
||||||
for wallet in wallets:
|
for wallet in wallets:
|
||||||
text.append(get_text_item_dict("{0}".format(wallet["name"]), 15))
|
text.append(get_text_item_dict(text="{0}".format(wallet["name"]), font_size=15,gerty_type=gerty.type))
|
||||||
text.append(
|
text.append(
|
||||||
get_text_item_dict("{0} sats".format(format_number(wallet["balance"])), 20)
|
get_text_item_dict(text="{0} sats".format(format_number(wallet["balance"])), font_size=20,gerty_type=gerty.type)
|
||||||
)
|
)
|
||||||
areas.append(text)
|
areas.append(text)
|
||||||
|
|
||||||
# Mempool fees
|
# Mempool fees
|
||||||
text = []
|
text = []
|
||||||
text.append(get_text_item_dict(format_number(await get_block_height(gerty)), 40))
|
text.append(get_text_item_dict(text=format_number(await get_block_height(gerty)), font_size=40,gerty_type=gerty.type))
|
||||||
text.append(get_text_item_dict("Current block height", 15))
|
text.append(get_text_item_dict(text="Current block height", font_size=15,gerty_type=gerty.type))
|
||||||
areas.append(text)
|
areas.append(text)
|
||||||
|
|
||||||
# difficulty adjustment time
|
# difficulty adjustment time
|
||||||
text = []
|
text = []
|
||||||
text.append(
|
text.append(
|
||||||
get_text_item_dict(
|
get_text_item_dict(
|
||||||
await get_time_remaining_next_difficulty_adjustment(gerty), 15
|
text=await get_time_remaining_next_difficulty_adjustment(gerty), font_size=15,gerty_type=gerty.type
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
text.append(get_text_item_dict("until next difficulty adjustment", 12))
|
text.append(get_text_item_dict(text="until next difficulty adjustment", font_size=12,gerty_type=gerty.type))
|
||||||
areas.append(text)
|
areas.append(text)
|
||||||
|
|
||||||
return areas
|
return areas
|
||||||
|
|
@ -276,21 +281,21 @@ async def get_lnbits_wallet_balances(gerty):
|
||||||
|
|
||||||
async def get_placeholder_text():
|
async def get_placeholder_text():
|
||||||
return [
|
return [
|
||||||
get_text_item_dict("Some placeholder text", 15, 10, 50),
|
get_text_item_dict(text="Some placeholder text", x_pos=15, y_pos=10, font_size=50,gerty_type=gerty.type),
|
||||||
get_text_item_dict("Some placeholder text", 15, 10, 50),
|
get_text_item_dict(text="Some placeholder text", x_pos=15, y_pos=10, font_size=50,gerty_type=gerty.type),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
async def get_satoshi_quotes():
|
async def get_satoshi_quotes(gerty):
|
||||||
# Get Satoshi quotes
|
# Get Satoshi quotes
|
||||||
text = []
|
text = []
|
||||||
quote = await api_gerty_satoshi()
|
quote = await api_gerty_satoshi()
|
||||||
if quote:
|
if quote:
|
||||||
if quote["text"]:
|
if quote["text"]:
|
||||||
text.append(get_text_item_dict(quote["text"], 15))
|
text.append(get_text_item_dict(text=quote["text"], font_size=15,gerty_type=gerty.type))
|
||||||
if quote["date"]:
|
if quote["date"]:
|
||||||
text.append(
|
text.append(
|
||||||
get_text_item_dict("Satoshi Nakamoto - {0}".format(quote["date"]), 15)
|
get_text_item_dict(text="Satoshi Nakamoto - {0}".format(quote["date"]), font_size=15,gerty_type=gerty.type)
|
||||||
)
|
)
|
||||||
return text
|
return text
|
||||||
|
|
||||||
|
|
@ -305,10 +310,10 @@ async def get_exchange_rate(gerty):
|
||||||
price = format_number(amount)
|
price = format_number(amount)
|
||||||
text.append(
|
text.append(
|
||||||
get_text_item_dict(
|
get_text_item_dict(
|
||||||
"Current {0}/BTC price".format(gerty.exchange), 15
|
text="Current {0}/BTC price".format(gerty.exchange), font_size=15,gerty_type=gerty.type
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
text.append(get_text_item_dict(price, 80))
|
text.append(get_text_item_dict(text=price, font_size=80,gerty_type=gerty.type))
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
return text
|
return text
|
||||||
|
|
@ -320,26 +325,27 @@ async def get_onchain_stat(stat_slug: str, gerty):
|
||||||
stat_slug == "onchain_difficulty_retarget_date" or
|
stat_slug == "onchain_difficulty_retarget_date" or
|
||||||
stat_slug == "onchain_difficulty_blocks_remaining" or
|
stat_slug == "onchain_difficulty_blocks_remaining" or
|
||||||
stat_slug == "onchain_difficulty_epoch_time_remaining"
|
stat_slug == "onchain_difficulty_epoch_time_remaining"
|
||||||
|
|
||||||
):
|
):
|
||||||
async with httpx.AsyncClient() as client:
|
async with httpx.AsyncClient() as client:
|
||||||
r = await client.get(gerty.mempool_endpoint + "/api/v1/difficulty-adjustment")
|
r = await client.get(gerty.mempool_endpoint + "/api/v1/difficulty-adjustment")
|
||||||
if stat_slug == "onchain_difficulty_epoch_progress":
|
if stat_slug == "onchain_difficulty_epoch_progress":
|
||||||
stat = round(r.json()['progressPercent'])
|
stat = round(r.json()['progressPercent'])
|
||||||
text.append(get_text_item_dict("Progress through current difficulty epoch", 15))
|
text.append(get_text_item_dict(text="Progress through current difficulty epoch", font_size=15,gerty_type=gerty.type))
|
||||||
text.append(get_text_item_dict("{0}%".format(stat), 80))
|
text.append(get_text_item_dict(text="{0}%".format(stat), font_size=80,gerty_type=gerty.type))
|
||||||
elif stat_slug == "onchain_difficulty_retarget_date":
|
elif stat_slug == "onchain_difficulty_retarget_date":
|
||||||
stat = r.json()['estimatedRetargetDate']
|
stat = r.json()['estimatedRetargetDate']
|
||||||
dt = datetime.fromtimestamp(stat / 1000).strftime("%e %b %Y at %H:%M")
|
dt = datetime.fromtimestamp(stat / 1000).strftime("%e %b %Y at %H:%M")
|
||||||
text.append(get_text_item_dict("Estimated date of next difficulty adjustment", 15))
|
text.append(get_text_item_dict(text="Date of next difficulty adjustment", font_size=15,gerty_type=gerty.type))
|
||||||
text.append(get_text_item_dict(dt, 40))
|
text.append(get_text_item_dict(text=dt, font_size=40,gerty_type=gerty.type))
|
||||||
elif stat_slug == "onchain_difficulty_blocks_remaining":
|
elif stat_slug == "onchain_difficulty_blocks_remaining":
|
||||||
stat = r.json()['remainingBlocks']
|
stat = r.json()['remainingBlocks']
|
||||||
text.append(get_text_item_dict("Blocks remaining until next difficulty adjustment", 15))
|
text.append(get_text_item_dict(text="Blocks until next difficulty adjustment", font_size=15,gerty_type=gerty.type))
|
||||||
text.append(get_text_item_dict("{0}".format(format_number(stat)), 80))
|
text.append(get_text_item_dict(text="{0}".format(format_number(stat)), font_size=80,gerty_type=gerty.type))
|
||||||
elif stat_slug == "onchain_difficulty_epoch_time_remaining":
|
elif stat_slug == "onchain_difficulty_epoch_time_remaining":
|
||||||
stat = r.json()['remainingTime']
|
stat = r.json()['remainingTime']
|
||||||
text.append(get_text_item_dict("Blocks remaining until next difficulty adjustment", 15))
|
text.append(get_text_item_dict(text="Time until next difficulty adjustment", font_size=15,gerty_type=gerty.type))
|
||||||
text.append(get_text_item_dict(get_time_remaining(stat / 1000, 4), 20))
|
text.append(get_text_item_dict(text=get_time_remaining(stat / 1000, 4), font_size=20,gerty_type=gerty.type))
|
||||||
return text
|
return text
|
||||||
|
|
||||||
async def get_onchain_dashboard(gerty):
|
async def get_onchain_dashboard(gerty):
|
||||||
|
|
@ -351,27 +357,27 @@ async def get_onchain_dashboard(gerty):
|
||||||
)
|
)
|
||||||
text = []
|
text = []
|
||||||
stat = round(r.json()["progressPercent"])
|
stat = round(r.json()["progressPercent"])
|
||||||
text.append(get_text_item_dict("Progress through epoch", 12))
|
text.append(get_text_item_dict(text="Progress through epoch", font_size=12,gerty_type=gerty.type))
|
||||||
text.append(get_text_item_dict("{0}%".format(stat), 60))
|
text.append(get_text_item_dict(text="{0}%".format(stat), font_size=60,gerty_type=gerty.type))
|
||||||
areas.append(text)
|
areas.append(text)
|
||||||
|
|
||||||
text = []
|
text = []
|
||||||
stat = r.json()["estimatedRetargetDate"]
|
stat = r.json()["estimatedRetargetDate"]
|
||||||
dt = datetime.fromtimestamp(stat / 1000).strftime("%e %b %Y at %H:%M")
|
dt = datetime.fromtimestamp(stat / 1000).strftime("%e %b %Y at %H:%M")
|
||||||
text.append(get_text_item_dict("Date of next adjustment", 12))
|
text.append(get_text_item_dict(text="Date of next adjustment", font_size=12,gerty_type=gerty.type))
|
||||||
text.append(get_text_item_dict(dt, 20))
|
text.append(get_text_item_dict(text=dt, font_size=20,gerty_type=gerty.type))
|
||||||
areas.append(text)
|
areas.append(text)
|
||||||
|
|
||||||
text = []
|
text = []
|
||||||
stat = r.json()["remainingBlocks"]
|
stat = r.json()["remainingBlocks"]
|
||||||
text.append(get_text_item_dict("Blocks until adjustment", 12))
|
text.append(get_text_item_dict(text="Blocks until adjustment", font_size=12,gerty_type=gerty.type))
|
||||||
text.append(get_text_item_dict("{0}".format(format_number(stat)), 60))
|
text.append(get_text_item_dict(text="{0}".format(format_number(stat)), font_size=60,gerty_type=gerty.type))
|
||||||
areas.append(text)
|
areas.append(text)
|
||||||
|
|
||||||
text = []
|
text = []
|
||||||
stat = r.json()["remainingTime"]
|
stat = r.json()["remainingTime"]
|
||||||
text.append(get_text_item_dict("Time until adjustment", 12))
|
text.append(get_text_item_dict(text="Time until adjustment", font_size=12,gerty_type=gerty.type))
|
||||||
text.append(get_text_item_dict(get_time_remaining(stat / 1000, 4), 20))
|
text.append(get_text_item_dict(text=get_time_remaining(stat / 1000, 4), font_size=20,gerty_type=gerty.type))
|
||||||
areas.append(text)
|
areas.append(text)
|
||||||
|
|
||||||
return areas
|
return areas
|
||||||
|
|
@ -404,30 +410,30 @@ async def get_mempool_stat(stat_slug: str, gerty):
|
||||||
r = await client.get(gerty.mempool_endpoint + "/api/mempool")
|
r = await client.get(gerty.mempool_endpoint + "/api/mempool")
|
||||||
if stat_slug == "mempool_tx_count":
|
if stat_slug == "mempool_tx_count":
|
||||||
stat = round(r.json()["count"])
|
stat = round(r.json()["count"])
|
||||||
text.append(get_text_item_dict("Transactions in the mempool", 15))
|
text.append(get_text_item_dict(text="Transactions in the mempool", font_size=15,gerty_type=gerty.type))
|
||||||
text.append(
|
text.append(
|
||||||
get_text_item_dict("{0}".format(format_number(stat)), 80)
|
get_text_item_dict(text="{0}".format(format_number(stat)), font_size=80,gerty_type=gerty.type)
|
||||||
)
|
)
|
||||||
elif stat_slug == "mempool_recommended_fees":
|
elif stat_slug == "mempool_recommended_fees":
|
||||||
y_offset = 60
|
y_offset = 60
|
||||||
fees = await get_mempool_recommended_fees(gerty)
|
fees = await get_mempool_recommended_fees(gerty)
|
||||||
pos_y = 80 + y_offset
|
pos_y = 80 + y_offset
|
||||||
text.append(get_text_item_dict("mempool.space", 40, 160, pos_y))
|
text.append(get_text_item_dict("mempool.space", 40, 160, pos_y, gerty.type))
|
||||||
pos_y = 180 + y_offset
|
pos_y = 180 + y_offset
|
||||||
text.append(get_text_item_dict("Recommended Tx Fees", 20, 240, pos_y))
|
text.append(get_text_item_dict("Recommended Tx Fees", 20, 240, pos_y, gerty.type))
|
||||||
|
|
||||||
pos_y = 280 + y_offset
|
pos_y = 280 + y_offset
|
||||||
text.append(
|
text.append(
|
||||||
get_text_item_dict("{0}".format("None"), 15, 30, pos_y)
|
get_text_item_dict("{0}".format("None"), 15, 30, pos_y, gerty.type)
|
||||||
)
|
)
|
||||||
text.append(
|
text.append(
|
||||||
get_text_item_dict("{0}".format("Low"), 15, 235, pos_y)
|
get_text_item_dict("{0}".format("Low"), 15, 235, pos_y, gerty.type)
|
||||||
)
|
)
|
||||||
text.append(
|
text.append(
|
||||||
get_text_item_dict("{0}".format("Medium"), 15, 460, pos_y)
|
get_text_item_dict("{0}".format("Medium"), 15, 460, pos_y, gerty.type)
|
||||||
)
|
)
|
||||||
text.append(
|
text.append(
|
||||||
get_text_item_dict("{0}".format("High"), 15, 750, pos_y)
|
get_text_item_dict("{0}".format("High"), 15, 750, pos_y, gerty.type)
|
||||||
)
|
)
|
||||||
|
|
||||||
pos_y = 340 + y_offset
|
pos_y = 340 + y_offset
|
||||||
|
|
@ -436,56 +442,60 @@ async def get_mempool_stat(stat_slug: str, gerty):
|
||||||
fee_rate = fees["economyFee"]
|
fee_rate = fees["economyFee"]
|
||||||
text.append(
|
text.append(
|
||||||
get_text_item_dict(
|
get_text_item_dict(
|
||||||
"{0} {1}{2}".format(
|
text="{0} {1}{2}".format(
|
||||||
format_number(fee_rate),
|
format_number(fee_rate),
|
||||||
("sat" if fee_rate == 1 else "sats"),
|
("sat" if fee_rate == 1 else "sats"),
|
||||||
fee_append,
|
fee_append,
|
||||||
),
|
),
|
||||||
font_size,
|
font_size=font_size,
|
||||||
30,
|
x_pos=30,
|
||||||
pos_y,
|
y_pos=pos_y,
|
||||||
|
gerty_type=gerty.type
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
fee_rate = fees["hourFee"]
|
fee_rate = fees["hourFee"]
|
||||||
text.append(
|
text.append(
|
||||||
get_text_item_dict(
|
get_text_item_dict(
|
||||||
"{0} {1}{2}".format(
|
text="{0} {1}{2}".format(
|
||||||
format_number(fee_rate),
|
format_number(fee_rate),
|
||||||
("sat" if fee_rate == 1 else "sats"),
|
("sat" if fee_rate == 1 else "sats"),
|
||||||
fee_append,
|
fee_append,
|
||||||
),
|
),
|
||||||
font_size,
|
font_size=font_size,
|
||||||
235,
|
x_pos=235,
|
||||||
pos_y,
|
y_pos=pos_y,
|
||||||
|
gerty_type=gerty.type
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
fee_rate = fees["halfHourFee"]
|
fee_rate = fees["halfHourFee"]
|
||||||
text.append(
|
text.append(
|
||||||
get_text_item_dict(
|
get_text_item_dict(
|
||||||
"{0} {1}{2}".format(
|
text="{0} {1}{2}".format(
|
||||||
format_number(fee_rate),
|
format_number(fee_rate),
|
||||||
("sat" if fee_rate == 1 else "sats"),
|
("sat" if fee_rate == 1 else "sats"),
|
||||||
fee_append,
|
fee_append,
|
||||||
),
|
),
|
||||||
font_size,
|
font_size=font_size,
|
||||||
460,
|
x_pos=460,
|
||||||
pos_y,
|
y_pos=pos_y,
|
||||||
|
gerty_type=gerty.type
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
fee_rate = fees["fastestFee"]
|
fee_rate = fees["fastestFee"]
|
||||||
text.append(
|
text.append(
|
||||||
get_text_item_dict(
|
get_text_item_dict(
|
||||||
"{0} {1}{2}".format(
|
text="{0} {1}{2}".format(
|
||||||
format_number(fee_rate),
|
format_number(fee_rate),
|
||||||
("sat" if fee_rate == 1 else "sats"),
|
("sat" if fee_rate == 1 else "sats"),
|
||||||
fee_append,
|
fee_append,
|
||||||
),
|
),
|
||||||
font_size,
|
font_size=font_size,
|
||||||
750,
|
x_pos=750,
|
||||||
pos_y,
|
y_pos=pos_y,
|
||||||
|
gerty_type=gerty.type
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
return text
|
return text
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue