Skip to content

Instantly share code, notes, and snippets.

@peerchemist
Last active November 21, 2020 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peerchemist/fda4b85fcccbb51a05187e46fbb86195 to your computer and use it in GitHub Desktop.
Save peerchemist/fda4b85fcccbb51a05187e46fbb86195 to your computer and use it in GitHub Desktop.
from peercoin_rpc import Client
# block found 2019-08-30
starting_block = 450000
node = Client(username="rpc", password="pass")
addresses = {}
def get_block_minter(blocknum: int):
blockhash = node.getblockhash(blocknum)
block = node.getblock(blockhash)
if block['flags'] == "proof-of-stake":
# Grab index 1 tx of the proof of stake block
pos_txn = node.getrawtransaction(block['tx'][1], True)
# Retreiving Minter address in which newly minted coins were sent to
minter = pos_txn["vout"][1]["scriptPubKey"]["addresses"][0]
# Grab the tx information for the utxo which successfully minted ( only will ever be one )
vin = node.getrawtransaction(pos_txn['vin'][0]['txid'], True)
# Grab the vout index number
vout_index_minted = pos_txn["vin"][0]["vout"]
# Retreiving the Value used to mint
input_value = float( vin["vout"][vout_index_minted]["value"] )
# Retreiving the Total amount returned to minter ( Value used to mint + Newly minted coins )
output_value = sum([float(i["value"]) for i in pos_txn["vout"]])
vote = {"block": blockhash, "minter": minter, "value": output_value - input_value}
if minter not in addresses:
addresses[minter] = vote["value"]
else:
addresses[minter] += vote["value"]
print(vote)
else:
print("PoW block.")
for i in range(starting_block, 530000):
get_block_minter(i)
print(addresses)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment