feat: Add start of hns-link

This commit is contained in:
Nathan Woodburn 2025-03-07 14:19:22 +11:00
parent 41cbe258c0
commit 64ee3a26e4
Signed by: nathanwoodburn
GPG Key ID: 203B000478AD0EF1

View File

@ -55,6 +55,25 @@ functions = {
}
}
},
"hnslinks":{
"name": "Add domain to HNS Links with wallet address",
"type": "default",
"description": "Add a domain to HNS Links",
"params": {
"domain": {
"name":"Domain",
"type":"text"
}
},
"returns": {
"status":
{
"name": "Status of the function",
"type": "text"
}
}
}
}
@ -152,4 +171,27 @@ def addDomain(params, authentication):
dns.append({'type': 'DS', 'keyTag': int(ds[0]), 'algorithm': int(ds[1]), 'digestType': int(ds[2]), 'digest': ds[3]})
dns = json.dumps(dns)
response = account.setDNS(authentication,domain,dns)
return {"status": "Success"}
return {"status": "Success"}
def hnslinks(params, authentication):
# Verify domain is owned by user
domain = params["domain"]
wallet = authentication.split(":")[0]
owned = account.getDomains(wallet)
# Only keep owned domains ["name"]
ownedNames = [domain["name"] for domain in owned]
if domain not in ownedNames:
return {"status": "Domain not owned by user"}
# Get wallet address
address = account.getAddress(wallet)
if address == "":
return {"status": "Error getting wallet address"}
# Sign message hns-links
response = account.signMessage(wallet,domain,"hns-links")
if "error" in response:
return {"status": "Error signing message"}
return {"status": response}