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

View File

@ -7,7 +7,7 @@ import binascii
import datetime import datetime
import dns.asyncresolver import dns.asyncresolver
import httpx 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): def hip2(domain: str):
@ -114,7 +114,7 @@ def hip2(domain: str):
# Catch all exceptions # Catch all exceptions
except Exception as e: 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"): def resolve_with_doh(query_name, doh_url="https://hnsdoh.com/dns-query"):

View File

@ -18,7 +18,7 @@
<body id="page-top"> <body id="page-top">
<div id="wrapper"> <div id="wrapper">
<nav class="navbar align-items-start sidebar sidebar-dark accordion bg-gradient-primary p-0 navbar-dark"> <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-icon"><img src="/assets/img/favicon.png" width="44"></div>
<div class="sidebar-brand-text mx-3"><span>FireWallet</span></div> <div class="sidebar-brand-text mx-3"><span>FireWallet</span></div>
</a> </a>

View File

@ -18,7 +18,7 @@
<body id="page-top"> <body id="page-top">
<div id="wrapper"> <div id="wrapper">
<nav class="navbar align-items-start sidebar sidebar-dark accordion bg-gradient-primary p-0 navbar-dark"> <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-icon"><img src="/assets/img/favicon.png" width="44"></div>
<div class="sidebar-brand-text mx-3"><span>FireWallet</span></div> <div class="sidebar-brand-text mx-3"><span>FireWallet</span></div>
</a> </a>

View File

@ -18,7 +18,7 @@
<body id="page-top"> <body id="page-top">
<div id="wrapper"> <div id="wrapper">
<nav class="navbar align-items-start sidebar sidebar-dark accordion bg-gradient-primary p-0 navbar-dark"> <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-icon"><img src="/assets/img/favicon.png" width="44"></div>
<div class="sidebar-brand-text mx-3"><span>FireWallet</span></div> <div class="sidebar-brand-text mx-3"><span>FireWallet</span></div>
</a> </a>

View File

@ -18,7 +18,7 @@
<body id="page-top"> <body id="page-top">
<div id="wrapper"> <div id="wrapper">
<nav class="navbar align-items-start sidebar sidebar-dark accordion bg-gradient-primary p-0 navbar-dark"> <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-icon"><img src="/assets/img/favicon.png" width="44"></div>
<div class="sidebar-brand-text mx-3"><span>FireWallet</span></div> <div class="sidebar-brand-text mx-3"><span>FireWallet</span></div>
</a> </a>

View File

@ -18,7 +18,7 @@
<body id="page-top"> <body id="page-top">
<div id="wrapper"> <div id="wrapper">
<nav class="navbar align-items-start sidebar sidebar-dark accordion bg-gradient-primary p-0 navbar-dark"> <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-icon"><img src="/assets/img/favicon.png" width="44"></div>
<div class="sidebar-brand-text mx-3"><span>FireWallet</span></div> <div class="sidebar-brand-text mx-3"><span>FireWallet</span></div>
</a> </a>