Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -255,7 +255,9 @@ def get_my_chain_rec(recipient_name=None):
|
|
| 255 |
except Exception:
|
| 256 |
try:
|
| 257 |
mychain_rec = MyChainRec(chain_load=main_balance,create=recipient_name)
|
| 258 |
-
response = mychain_rec.chain
|
|
|
|
|
|
|
| 259 |
message = f"Blockchain loaded from: {main_balance}{recipient_name}.json"
|
| 260 |
return response,message
|
| 261 |
except Exception:
|
|
@@ -355,18 +357,29 @@ def issue_tokens(send,rec,amount):
|
|
| 355 |
pass
|
| 356 |
if p==True:
|
| 357 |
balance = lod[-1]["balance"]
|
| 358 |
-
|
| 359 |
balance_send =int(balance)-int(amount)
|
| 360 |
if balance_send >=0:
|
| 361 |
p=True
|
|
|
|
| 362 |
response,message = get_my_chain_rec(rec)
|
| 363 |
#lod_rec = json.loads(response)
|
| 364 |
lod_rec = response
|
| 365 |
-
|
| 366 |
-
|
| 367 |
-
|
| 368 |
-
|
| 369 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 370 |
balance_rec =int(balance)+int(amount)
|
| 371 |
|
| 372 |
if balance_send < 0:
|
|
|
|
| 255 |
except Exception:
|
| 256 |
try:
|
| 257 |
mychain_rec = MyChainRec(chain_load=main_balance,create=recipient_name)
|
| 258 |
+
response = {'chain': mychain_rec.chain,
|
| 259 |
+
'length': len(mychain_rec.chain)}
|
| 260 |
+
|
| 261 |
message = f"Blockchain loaded from: {main_balance}{recipient_name}.json"
|
| 262 |
return response,message
|
| 263 |
except Exception:
|
|
|
|
| 357 |
pass
|
| 358 |
if p==True:
|
| 359 |
balance = lod[-1]["balance"]
|
| 360 |
+
print (balance)
|
| 361 |
balance_send =int(balance)-int(amount)
|
| 362 |
if balance_send >=0:
|
| 363 |
p=True
|
| 364 |
+
|
| 365 |
response,message = get_my_chain_rec(rec)
|
| 366 |
#lod_rec = json.loads(response)
|
| 367 |
lod_rec = response
|
| 368 |
+
try:
|
| 369 |
+
if lod_rec["chain"][-1]["index"] > 1:
|
| 370 |
+
balance = lod_rec[-1]["balance"]
|
| 371 |
+
if lod_rec["chain"][-1]["index"] == 1:
|
| 372 |
+
balance = 0
|
| 373 |
+
except Exception:
|
| 374 |
+
p=False
|
| 375 |
+
try:
|
| 376 |
+
if lod_rec["chain"][0]["index"] > 1:
|
| 377 |
+
balance = lod_rec[-1]["balance"]
|
| 378 |
+
if lod_rec["chain"][0]["index"] == 1:
|
| 379 |
+
balance = 0
|
| 380 |
+
p=True
|
| 381 |
+
except Exception:
|
| 382 |
+
p=False
|
| 383 |
balance_rec =int(balance)+int(amount)
|
| 384 |
|
| 385 |
if balance_send < 0:
|