Hello, I'm trying to write a script that reproduces the totalsubsidy field in dcrctl --wallet getstakeinfo on a per vote basis. Specifically, I'm interested in the individual points in time when voting subsidy was received. Code: #!/usr/bin/env python import requests url = "https://mainnet.decred.org/api/txs/?address=D..." r = requests.get(url).json() txs = r["txs"] vins = [] for tx in sorted(txs, key=lambda tx: tx["time"]): if not tx.get("isStakeGen", False): continue for vin in tx["vin"]: if vin.get("isStakeBase", False): vins.append(vin) sum(vins) However, using the above code I end up with a much lower number compared to totalsubsidy. Am I missing an important part of the voting process? Thanks
Please consider this as solved. I simply forgot I was once mining on another stake pool. I will post the complete code that also includes the mempool fee in the next days for anyone interested.
Getting data from the local dcrd instance would be much faster and private (no exposing of your address to the web), but in any case this is useful. I suggest posting to GitHub when ready, for easier collaboration.
Hello, It's me again. I've completed the code for calculating PoS profits. However, my final balance is lower than what should be expected according to the script below. I think it has something to do with fees. Could somebody please look at the code below and let me know if I'm missing a fee in the PoS process? Thanks! Code: import requests import csv import pandas as pd pd.set_option('display.max_colwidth', -1) addrs = [ ..., ..., ] def get_txs(addrs): txs = [] for addr in addrs: url = "https://mainnet.decred.org/api/txs/?address={}".format(addr) txs.extend(requests.get(url).json()["txs"]) return txs txs = get_txs(addrs) txd = dict((v["txid"], v) for v in txs) txs = sorted(txs, key=lambda tx: tx["blocktime"]) txlist = [] for tx in txs: if not tx.get("isStakeGen", False): continue subsidy_tx = [i for i in tx["vin"] if i.get("stakebase") == "0000"][0] txlist.append({ "time": tx["blocktime"], #"ticketid": tx["ticketid"], "fees": txd[tx["ticketid"]]["fees"], # I think I need to add another fee here "txid": tx["txid"], "subsidy": subsidy_tx["amountin"] }) txdf = pd.DataFrame.from_records(txlist) print(txdf.subsidy.sum() - txdf.fees.sum())