feat: Add transfer finalize
This commit is contained in:
parent
ba7a73d1a9
commit
cd362f805b
50
firesales.py
50
firesales.py
@ -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": {
|
"list": {
|
||||||
"name": "List",
|
"name": "List",
|
||||||
"description": "List a new domain",
|
"description": "List a new domain",
|
||||||
@ -144,10 +165,37 @@ def startListingTransfer(params, authentication):
|
|||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
stderr=subprocess.STDOUT
|
stderr=subprocess.STDOUT
|
||||||
)
|
)
|
||||||
|
|
||||||
# Wait for the process to finish
|
# Wait for the process to finish
|
||||||
stdout, stderr = process.communicate()
|
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 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"STDOUT: {stdout}")
|
||||||
print(f"STDERR: {stderr}")
|
print(f"STDERR: {stderr}")
|
||||||
|
|
||||||
|
@ -276,11 +276,6 @@ async function transferLock(name) {
|
|||||||
async function finalizeLock(name) {
|
async function finalizeLock(name) {
|
||||||
const {db, context} = await setupCLI();
|
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);
|
const nameState = await db.getOutboundNameState(name);
|
||||||
if (nameState === null) {
|
if (nameState === null) {
|
||||||
die(`Name ${name} not found.`);
|
die(`Name ${name} not found.`);
|
||||||
@ -318,10 +313,6 @@ async function finalizeLock(name) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function transferLockCancel(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();
|
const {db, context} = await setupCLI();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user