feat: Add tx count function
This commit is contained in:
parent
57cc850e1a
commit
e85b809f59
28
testing.py
28
testing.py
@ -33,6 +33,19 @@ functions = {
|
|||||||
"type": "text"
|
"type": "text"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"txCount":{
|
||||||
|
"name": "Count TXs",
|
||||||
|
"type": "default",
|
||||||
|
"description": "Get the number of TXs",
|
||||||
|
"params": {},
|
||||||
|
"returns": {
|
||||||
|
"txs":
|
||||||
|
{
|
||||||
|
"name": "Transactions",
|
||||||
|
"type": "text"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,4 +63,19 @@ def generate(params, authentication):
|
|||||||
print(f"Generating {number} blocks to {address}")
|
print(f"Generating {number} blocks to {address}")
|
||||||
blocks = account.hsd.rpc_generateToAddress(address,number)
|
blocks = account.hsd.rpc_generateToAddress(address,number)
|
||||||
return {"status": f"Successfully generated {number} blocks to {address}"}
|
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}'}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user