You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#2 gets us much closer, but it's undercounting coins because it's not using the original improved algorithm:
// For each block, account for P2PK coinsfor height in resume_height..tip_height {let hash = rpc.get_block_hash(height)?;let block = rpc.get_block(&hash)?;// Account for the new P2PK coinsfor tx in block.txdata.iter(){for outpoint in&tx.output{if outpoint.script_pubkey.is_p2pk(){
p2pk_addresses += 1;
p2pk_coins += outpoint.value.to_btc();}}// If the transaction is not coinbase, account for the spent coinsif !tx.is_coinbase(){for txin in&tx.input{let txid = txin.previous_output.txid;let vout = txin.previous_output.vout;let prev_tx = rpc.get_raw_transaction(&txid,None)?;// Check if the specific output being spent was P2PKifletSome(prev_output) = prev_tx.output.get(vout asusize){if prev_output.script_pubkey.is_p2pk(){
p2pk_addresses -= 1;
p2pk_coins -= prev_output.value.to_btc();}}}}}}
For this, we need to create a BTreeMap<[u8; 32], bool>, with the bool as to whether the prevout is a P2PK spend script. This is more memory efficient than storing the entire spend script. Ideally we put only txs that contain a P2PK spend script into the BTreeMap.
The text was updated successfully, but these errors were encountered:
#2 gets us much closer, but it's undercounting coins because it's not using the original improved algorithm:
For this, we need to create a BTreeMap<[u8; 32], bool>, with the bool as to whether the prevout is a P2PK spend script. This is more memory efficient than storing the entire spend script. Ideally we put only txs that contain a P2PK spend script into the BTreeMap.
The text was updated successfully, but these errors were encountered: