feat: Add transfer finalize

This commit is contained in:
Nathan Woodburn 2025-01-30 22:31:17 +11:00
parent ba7a73d1a9
commit cd362f805b
Signed by: nathanwoodburn
GPG Key ID: 203B000478AD0EF1
2 changed files with 50 additions and 11 deletions

View File

@ -49,6 +49,27 @@ functions = {
}
}
},
"finalizeListingTransfer": {
"name": "Finalize Listing Transfer",
"description": "Finalize listing transfer",
"type":"default",
"params": {
"domain": {
"type": "text",
"name": "Domain to list"
}
},
"returns": {
"status": {
"type": "text",
"name": "Status"
},
"txid": {
"type": "tx",
"name": "Transaction ID"
}
}
},
"list": {
"name": "List",
"description": "List a new domain",
@ -144,10 +165,8 @@ def startListingTransfer(params, authentication):
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT
)
# Wait for the process to finish
stdout, stderr = process.communicate()
print(f"STDOUT: {stdout}")
print(f"STDERR: {stderr}")
@ -158,6 +177,35 @@ def startListingTransfer(params, authentication):
txhash = txhash.split("\n")[0].rstrip('.')
return {"status": "Success", "txid": txhash}
def finalizeListingTransfer(params, authentication):
domain = params["domain"]
# Generate command
wallet = authentication.split(":")[0]
passphrase = authentication.split(":")[1]
api_key = os.getenv("hsd_api")
host = os.getenv("hsd_ip")
if host is None:
host = "127.0.0.1"
# node node_modules/shakedex/bin/shakedex transfer-lock domain -n main -w wallet -a key -p ./data --httphost host
process = subprocess.Popen(
["node", f"{path}/node_modules/shakedex/bin/shakedex", "finalize-lock", domain, "-n", "main", "-w", wallet, "-a", api_key, "-p", f"{path}/data", "--httphost", host, "-P", passphrase],
text=True,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT
)
# Wait for the process to finish
stdout, stderr = process.communicate()
print(f"STDOUT: {stdout}")
print(f"STDERR: {stderr}")
if process.returncode != 0:
return {"status": f"Error: {stderr}", "txid": None}
txhash:str = stdout.split(" hash ")[1]
txhash = txhash.split("\n")[0].rstrip('.')
return {"status": "Success", "txid": txhash}
def list(params, authentication):
domain = params["domain"]
price = params["price"]

View File

@ -276,11 +276,6 @@ async function transferLock(name) {
async function finalizeLock(name) {
const {db, context} = await setupCLI();
await confirm(
`Your transfer of ${name} to the locking script will be finalized. ` +
'This can be undone, but requires additional on-chain transactions. Do you wish to continue?',
);
const nameState = await db.getOutboundNameState(name);
if (nameState === null) {
die(`Name ${name} not found.`);
@ -318,10 +313,6 @@ async function finalizeLock(name) {
}
async function transferLockCancel(name) {
await confirm(
`Your transfer of ${name} to the locking script will be cancelled. You will need to finalize this ` +
'transfer to regain ownership of the name. Do you wish to continue?',
);
const {db, context} = await setupCLI();