-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
175 lines (123 loc) · 4.35 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
import flet as ft
from flet import ViewPopEvent, View, RouteChangeEvent
from common.cartera import Cartera, DEFAULT_DATABASE
from views.transactiondetail_view import trans_detail
from views.send_view import send_view
from views.receive_view import receive_view
from views.transactions_view import transaction_view
from views.main_view import main_view
from views.service_view import service_view
from views.signup_view import create
from bitcoinlib.wallets import wallet_exists
from views.paymentinfo_view import paymentInfo
from views.settings_view import settings_view
from views.signup import signup
from views.fee import fee
from views.import_view import importar, bip38_import
#passphrases = "divorce frame wonder arrange gold chalk south original ceiling submit arena settle"
passphrases = None
offline_tansactions = False
#mwallet = None
CURRENT_WALLET = "bitcoin"
def main(page: ft.Page):
page.title = "NAIA WALLET"
print("Initial route:", page.route)
page.vertical_alignment = ft.MainAxisAlignment.CENTER
page.horizontal_alignment = ft.CrossAxisAlignment.CENTER
page.snack_bar = ft.SnackBar(
content=ft.Text("Hello, world!"),
action="Alright!",
)
#VISTAS
def route_change(e: RouteChangeEvent):
page.views.clear()
troute = ft.TemplateRoute(page.route)
mwallet = None
if wallet_exists(CURRENT_WALLET, DEFAULT_DATABASE):
mwallet = Cartera(network="testnet")
#VISTA PRINCIPAL
page.views.append(
signup(page) if not wallet_exists(CURRENT_WALLET, DEFAULT_DATABASE) else main_view(mwallet, page)
)
if page.route == "/load":
page.views.append(
#load(page)
signup(page)
)
if page.route == "/crear":
page.views.append(
#load(page)
create(page)
)
if page.route == "/main":
page.views.append(
main_view(mwallet, page)
)
#VISTA TRANSACIONES
if page.route == "/transacciones":
page.views.append(
transaction_view(page, mwallet)
)
if page.route == "/fee":
page.views.append(
fee(page, mwallet),
)
#VISTA PARA RECIBIR BTC
if page.route == "/recibir":
#VISTA DE PAGO RECIBIR
page.views.append(
receive_view(mwallet, page)
)
if page.route == "/importar":
#VISTA DE PAGO RECIBIR
page.views.append(
importar(page)
)
#VISTA PARA ENVIAR BTC
if page.route == "/enviar":
page.views.append(
#VISTA DE ENVIAR BTC
send_view(mwallet, page, offline=offline_tansactions)
)
#VISTA DETALLE DE TRANSACCION
if troute.match("/transaccions/:txid/:output_n"):
page.views.append(
trans_detail(mwallet, troute.txid, troute.output_n)
)
if troute.match("/comprobante/:txid"):
page.views.append(
paymentInfo(mwallet, troute.txid)
)
if troute.match("/importar/password/:key/:istestnet/:witnessType"):
page.views.append(
bip38_import(troute.key, troute.istestnet,troute.witnessType, page)
)
if page.route == "/service":
page.views.append(
service_view(page, mwallet)
)
if page.route == "/settings":
page.views.append(
settings_view(page=page)
)
page.update()
""" def view_pop(view):
page.views.pop()
if not page.route in ['/load', '/main', '/']:
top_view = page.views[-1]
page.go("/")
else:
top_view = page.views[0]
page.go(top_view)
#
page.on_route_change = route_change
page.on_view_pop = view_pop
page.go(page.route)"""
def view_pop(e: ViewPopEvent)-> None:
page.views.pop()
top_vew: View = page.views[-1]
page.go(top_vew.route)
page.on_route_change = route_change
page.on_view_pop = view_pop
page.go(page.route)
ft.app(main)