forked from HannahMR/tapd-python-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
new-address.py
31 lines (24 loc) · 740 Bytes
/
new-address.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import requests
import base64
import json
import codecs
from settings import REST_HOST, MACAROON_PATH, TLS_PATH
def main():
url = f"https://{REST_HOST}/v1/taproot-assets/addrs"
macaroon = codecs.encode(open(MACAROON_PATH, "rb").read(), "hex")
headers = {"Grpc-Metadata-macaroon": macaroon}
data = {
"asset_id": "id string here",
"amt": 1000,
"tapscript_sibling": "",
}
response = requests.post(
url, headers=headers, data=json.dumps(data), verify=TLS_PATH
)
if response.status_code == 200:
response_data = response.json()
print("Response from tapd:", response_data)
else:
print("Error:", response.text)
if __name__ == "__main__":
main()