Last active
July 12, 2022 11:59
-
-
Save cdm/e13a2d90103ee2eeac9392afcf4f46f8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
import os | |
import requests | |
transfer_id = "fa1a3ceb74b6b8b1525f44bf688569bcd8d7ca74a93cbcbbd8012001094e0a95" | |
node_url_rest = os.getenv("NODE_URL_REST") | |
wallet_server_url = os.getenv("WALLETSERVER_URL") | |
wallet_name = os.getenv("WALLET_NAME") | |
wallet_passphrase = os.getenv("WALLET_PASSPHRASE") | |
print(f"Logging into wallet: {wallet_name}") | |
# Log in to an existing wallet | |
req = {"wallet": wallet_name, "passphrase": wallet_passphrase} | |
response = requests.post(f"{wallet_server_url}/api/v1/auth/token", json=req) | |
token = response.json()["token"] | |
assert token != "" | |
print("Logged in to wallet successfully") | |
# List key pairs and select public key to use | |
headers = {"Authorization": f"Bearer {token}"} | |
response = requests.get(f"{wallet_server_url}/api/v1/keys", headers=headers) | |
keys = response.json()["keys"] | |
pubkey = keys[0]["pub"] | |
assert pubkey != "" | |
print(f"Selected pubkey: {pubkey}") | |
print() | |
# Build and send the cancel transfer request... | |
print(f"Cancelling transfer with ID {transfer_id}") | |
print() | |
transfer = { | |
"cancelTransfer":{ | |
"transferId": transfer_id | |
}, | |
"pubKey": pubkey, | |
"propagate": True | |
} | |
print(transfer) | |
url = f"{wallet_server_url}/api/v1/command/sync" | |
response = requests.post(url, headers=headers, json=transfer) | |
print("Signed cancel transfer command and sent to Vega") | |
print(response.json()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment