feat: Add custom exporter
This commit is contained in:
parent
df93add104
commit
60825554d1
89
exporter.py
Normal file
89
exporter.py
Normal file
@ -0,0 +1,89 @@
|
||||
import json
|
||||
import account
|
||||
import requests
|
||||
|
||||
# Plugin Data
|
||||
info = {
|
||||
"name": "Custom Exporter",
|
||||
"description": "Export info about your wallet with more control",
|
||||
"version": "1.0",
|
||||
"author": "Nathan.Woodburn/"
|
||||
}
|
||||
|
||||
# Functions
|
||||
functions = {
|
||||
"domainExport":{
|
||||
"name": "Export domain info",
|
||||
"type": "default",
|
||||
"description": "Use custom format to export domain data<br>Options are: name, expiry, value, maxBid, state, expiryBlock, openHeight",
|
||||
"params": {
|
||||
"format": {
|
||||
"name": "Format",
|
||||
"type": "text",
|
||||
}
|
||||
},
|
||||
"returns": {
|
||||
"status":
|
||||
{
|
||||
"name": "Status of the function",
|
||||
"type": "text"
|
||||
}
|
||||
}
|
||||
},
|
||||
"transactionExport":{
|
||||
"name": "Export transaction info",
|
||||
"type": "default",
|
||||
"description": "Use custom format to export transaction data<br>Options are: hash,height,time,mtime,date,mdate,size,virtualSize,fee,rate,confirmations",
|
||||
"params": {
|
||||
"format": {
|
||||
"name": "Format",
|
||||
"type": "text",
|
||||
}
|
||||
},
|
||||
"returns": {
|
||||
"status":
|
||||
{
|
||||
"name": "Status of the function",
|
||||
"type": "text"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def domainExport(params, authentication):
|
||||
format = params["format"]
|
||||
format = format.split(',')
|
||||
formatStr = ""
|
||||
for item in format:
|
||||
formatStr += "{" + item.strip() + "},"
|
||||
formatStr = formatStr.removesuffix(",")
|
||||
report = account.generateReport(authentication.split(":")[0],formatStr)
|
||||
with open("user_data/report.csv", "w") as f:
|
||||
f.write("\n".join(report))
|
||||
|
||||
return {"status": "Success saved in user_data"}
|
||||
|
||||
def transactionExport(params, authentication):
|
||||
format = params["format"]
|
||||
report = format
|
||||
format = format.split(',')
|
||||
format = [item.strip() for item in format]
|
||||
|
||||
transactions = account.getTransactions(authentication.split(":")[0])
|
||||
for tx in transactions:
|
||||
for item in format:
|
||||
if item in tx:
|
||||
if item == "outputs" or item == "inputs":
|
||||
# Escape to make sure it doesn't break the csv
|
||||
continue
|
||||
else:
|
||||
report += f"{tx[item]},"
|
||||
else:
|
||||
report += f"{item},"
|
||||
report.removesuffix(",")
|
||||
report += "\n"
|
||||
|
||||
with open("user_data/report.csv", "w") as f:
|
||||
f.write(report)
|
||||
|
||||
return {"status": "Success saved in user_data"}
|
Loading…
Reference in New Issue
Block a user