fix: Update to use better sending api

This commit is contained in:
Nathan Woodburn 2023-12-28 16:32:20 +11:00
parent c0b407a6a2
commit 713b33d05f
Signed by: nathanwoodburn
GPG Key ID: 203B000478AD0EF1
7 changed files with 25 additions and 27 deletions

View File

@ -128,6 +128,9 @@ def check_hip2(domain: str):
return 'Invalid address'
address = domainLookup.hip2(domain)
if address.startswith("Hip2: "):
return address
if not check_address(address, False,True):
return 'Hip2: Lookup succeeded but address is invalid'
return address
@ -139,32 +142,27 @@ def send(account,address,amount):
password = ":".join(account.split(":")[1:])
# Unlock the account
response = requests.post(f"http://x:{APIKEY}@127.0.0.1:12039/wallet/{account_name}/unlock",
json={"passphrase": password,"timeout": 10})
if response.status_code != 200:
response = hsw.rpc_selectWallet(account_name)
if response['error'] is not None:
return {
"error": "Failed to unlock account"
}
if 'success' not in response.json():
return {
"error": "Failed to unlock account"
"error": response['error']['message']
}
# Send the transaction
response = requests.post(f"http://x:{APIKEY}@127.0.0.1:12039",json={
"method": "sendtoaddress",
"params": [address,amount]
})
if response.status_code != 200:
response = hsw.rpc_walletPassphrase(password,10)
# Unlock the account
# response = requests.post(f"http://x:{APIKEY}@127.0.0.1:12039/wallet/{account_name}/unlock",
# json={"passphrase": password,"timeout": 10})
if response['error'] is not None:
return {
"error": "Failed to send transaction"
"error": response['error']['message']
}
response = response.json()
if 'error' in response:
response = hsw.rpc_sendToAddress(address,amount)
if response['error'] is not None:
return {
"error": json.dumps(response['error'])
"error": response['error']['message']
}
return {
"tx": response['result']

View File

@ -7,7 +7,7 @@ import binascii
import datetime
import dns.asyncresolver
import httpx
from requests_doh import DNSOverHTTPSSession, add_dns_provider, remove_dns_provider
from requests_doh import DNSOverHTTPSSession, add_dns_provider
def hip2(domain: str):
@ -114,7 +114,7 @@ def hip2(domain: str):
# Catch all exceptions
except Exception as e:
return "Hip2: " + str(e)
return "Hip2: Lookup failed."
def resolve_with_doh(query_name, doh_url="https://hnsdoh.com/dns-query"):

View File

@ -18,7 +18,7 @@
<body id="page-top">
<div id="wrapper">
<nav class="navbar align-items-start sidebar sidebar-dark accordion bg-gradient-primary p-0 navbar-dark">
<div class="container-fluid d-flex flex-column p-0"><a class="navbar-brand d-flex justify-content-center align-items-center sidebar-brand m-0" href="#">
<div class="container-fluid d-flex flex-column p-0"><a class="navbar-brand d-flex justify-content-center align-items-center sidebar-brand m-0" href="/">
<div class="sidebar-brand-icon"><img src="/assets/img/favicon.png" width="44"></div>
<div class="sidebar-brand-text mx-3"><span>FireWallet</span></div>
</a>

View File

@ -18,7 +18,7 @@
<body id="page-top">
<div id="wrapper">
<nav class="navbar align-items-start sidebar sidebar-dark accordion bg-gradient-primary p-0 navbar-dark">
<div class="container-fluid d-flex flex-column p-0"><a class="navbar-brand d-flex justify-content-center align-items-center sidebar-brand m-0" href="#">
<div class="container-fluid d-flex flex-column p-0"><a class="navbar-brand d-flex justify-content-center align-items-center sidebar-brand m-0" href="/">
<div class="sidebar-brand-icon"><img src="/assets/img/favicon.png" width="44"></div>
<div class="sidebar-brand-text mx-3"><span>FireWallet</span></div>
</a>

View File

@ -18,7 +18,7 @@
<body id="page-top">
<div id="wrapper">
<nav class="navbar align-items-start sidebar sidebar-dark accordion bg-gradient-primary p-0 navbar-dark">
<div class="container-fluid d-flex flex-column p-0"><a class="navbar-brand d-flex justify-content-center align-items-center sidebar-brand m-0" href="#">
<div class="container-fluid d-flex flex-column p-0"><a class="navbar-brand d-flex justify-content-center align-items-center sidebar-brand m-0" href="/">
<div class="sidebar-brand-icon"><img src="/assets/img/favicon.png" width="44"></div>
<div class="sidebar-brand-text mx-3"><span>FireWallet</span></div>
</a>

View File

@ -18,7 +18,7 @@
<body id="page-top">
<div id="wrapper">
<nav class="navbar align-items-start sidebar sidebar-dark accordion bg-gradient-primary p-0 navbar-dark">
<div class="container-fluid d-flex flex-column p-0"><a class="navbar-brand d-flex justify-content-center align-items-center sidebar-brand m-0" href="#">
<div class="container-fluid d-flex flex-column p-0"><a class="navbar-brand d-flex justify-content-center align-items-center sidebar-brand m-0" href="/">
<div class="sidebar-brand-icon"><img src="/assets/img/favicon.png" width="44"></div>
<div class="sidebar-brand-text mx-3"><span>FireWallet</span></div>
</a>

View File

@ -18,7 +18,7 @@
<body id="page-top">
<div id="wrapper">
<nav class="navbar align-items-start sidebar sidebar-dark accordion bg-gradient-primary p-0 navbar-dark">
<div class="container-fluid d-flex flex-column p-0"><a class="navbar-brand d-flex justify-content-center align-items-center sidebar-brand m-0" href="#">
<div class="container-fluid d-flex flex-column p-0"><a class="navbar-brand d-flex justify-content-center align-items-center sidebar-brand m-0" href="/">
<div class="sidebar-brand-icon"><img src="/assets/img/favicon.png" width="44"></div>
<div class="sidebar-brand-text mx-3"><span>FireWallet</span></div>
</a>