feat: Implement getting pending redeems
All checks were successful
Build Docker / Build Image (push) Successful in 44s
All checks were successful
Build Docker / Build Image (push) Successful in 44s
This commit is contained in:
parent
b5c3075fba
commit
7a4300066f
28
account.py
28
account.py
@ -600,11 +600,31 @@ def getPendingReveals(account):
|
|||||||
pending.append(bid)
|
pending.append(bid)
|
||||||
return pending
|
return pending
|
||||||
|
|
||||||
#! TODO
|
|
||||||
def getPendingRedeems(account):
|
def getPendingRedeems(account,password):
|
||||||
bids = getBids(account)
|
hsw.rpc_selectWallet(account)
|
||||||
domains = getDomains(account,False)
|
hsw.rpc_walletPassphrase(password,10)
|
||||||
|
tx = hsw.rpc_createREDEEM('','default')
|
||||||
|
if tx['error']:
|
||||||
|
return []
|
||||||
|
|
||||||
pending = []
|
pending = []
|
||||||
|
try:
|
||||||
|
for output in tx['result']['outputs']:
|
||||||
|
if output['covenant']['type'] != 5:
|
||||||
|
continue
|
||||||
|
if output['covenant']['action'] != "REDEEM":
|
||||||
|
continue
|
||||||
|
nameHash = output['covenant']['items'][0]
|
||||||
|
# Try to get the name from hash
|
||||||
|
name = hsd.rpc_getNameByHash(nameHash)
|
||||||
|
if name['error']:
|
||||||
|
pending.append(nameHash)
|
||||||
|
else:
|
||||||
|
pending.append(name['result'])
|
||||||
|
except:
|
||||||
|
print("Failed to parse redeems")
|
||||||
|
|
||||||
return pending
|
return pending
|
||||||
|
|
||||||
def getPendingRegisters(account):
|
def getPendingRegisters(account):
|
||||||
|
3
main.py
3
main.py
@ -1489,6 +1489,7 @@ def api_wallet(function):
|
|||||||
return jsonify({"error": "Not logged in"})
|
return jsonify({"error": "Not logged in"})
|
||||||
|
|
||||||
account = account_module.check_account(request.cookies.get("account"))
|
account = account_module.check_account(request.cookies.get("account"))
|
||||||
|
password = request.cookies.get("account").split(":")[1]
|
||||||
if not account:
|
if not account:
|
||||||
return jsonify({"error": "Invalid account"})
|
return jsonify({"error": "Invalid account"})
|
||||||
|
|
||||||
@ -1515,7 +1516,7 @@ def api_wallet(function):
|
|||||||
if function == "pendingRegister":
|
if function == "pendingRegister":
|
||||||
return jsonify({"result": len(account_module.getPendingRegisters(account))})
|
return jsonify({"result": len(account_module.getPendingRegisters(account))})
|
||||||
if function == "pendingRedeem":
|
if function == "pendingRedeem":
|
||||||
return jsonify({"result": len(account_module.getPendingRedeems(account))})
|
return jsonify({"result": len(account_module.getPendingRedeems(account,password))})
|
||||||
|
|
||||||
|
|
||||||
return jsonify({"error": "Invalid function", "result": "Invalid function"}), 400
|
return jsonify({"error": "Invalid function", "result": "Invalid function"}), 400
|
||||||
|
Loading…
Reference in New Issue
Block a user