feat: Add tx count function

This commit is contained in:
Nathan Woodburn 2025-02-01 16:52:08 +11:00
parent 57cc850e1a
commit e85b809f59
Signed by: nathanwoodburn
GPG Key ID: 203B000478AD0EF1

View File

@ -33,6 +33,19 @@ functions = {
"type": "text"
}
}
},
"txCount":{
"name": "Count TXs",
"type": "default",
"description": "Get the number of TXs",
"params": {},
"returns": {
"txs":
{
"name": "Transactions",
"type": "text"
}
}
}
}
@ -51,3 +64,18 @@ def generate(params, authentication):
blocks = account.hsd.rpc_generateToAddress(address,number)
return {"status": f"Successfully generated {number} blocks to {address}"}
def txCount(params, authentication):
wallet = authentication.split(":")[0]
txCount = 0
page = 1
while True:
txs = account.getTransactions(wallet,page)
if len(txs) == 0:
break
txCount += len(txs)
page += 1
return {"txs": f'Total TXs: {txCount}'}