Skip to content

Commit 2f6f699

Browse files
authored
Merge pull request #67 from rustaceanrob/26-3-3-bip30-unspendable
Account for BIP30 unspendable
2 parents 531262f + 0538cf5 commit 2f6f699

1 file changed

Lines changed: 25 additions & 4 deletions

File tree

node/src/lib.rs

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use bitcoin::{
1717
key::rand::{seq::SliceRandom, thread_rng},
1818
script::ScriptExt,
1919
transaction::TransactionExt,
20-
BlockHash, Network, OutPoint,
20+
BlockChecked, BlockHash, Network, OutPoint,
2121
};
2222
use hintsfile::Hintsfile;
2323
use kernel::{ChainType, ChainstateManager};
@@ -258,18 +258,20 @@ pub fn get_blocks_for_range(
258258
.expect("failed to write block file");
259259
file.sync_data().expect("could not sync file with OS");
260260
}
261-
let (_, transactions) = block.into_parts();
261+
let block = block.assume_checked(None);
262262
let mut output_index = 0;
263-
for transaction in transactions {
263+
for transaction in block.transactions() {
264264
let tx_hash = transaction.compute_txid();
265265
if !transaction.is_coinbase() {
266-
for input in transaction.inputs {
266+
for input in &transaction.inputs {
267267
let input_hash = aggregate::hash_outpoint(input.previous_output);
268268
let update = AggregateUpdate::Spent(input_hash);
269269
updater
270270
.send(update)
271271
.expect("accumulator task must not panic");
272272
}
273+
} else if block.is_bip30_unspendable(block_height) {
274+
continue;
273275
}
274276
for (vout, txout) in transaction.outputs.iter().enumerate() {
275277
if txout.script_pubkey.is_op_return()
@@ -388,3 +390,22 @@ impl ChainExt for Network {
388390
}
389391
}
390392
}
393+
394+
trait Bip30UnspendableExt {
395+
fn is_bip30_unspendable(&self, height: u32) -> bool;
396+
}
397+
398+
impl Bip30UnspendableExt for bitcoin::Block<BlockChecked> {
399+
fn is_bip30_unspendable(&self, height: u32) -> bool {
400+
height == 91722
401+
&& "00000000000271a2dc26e7667f8419f2e15416dc6955e5a6c6cdf3f2574dd08e"
402+
.parse::<BlockHash>()
403+
.unwrap()
404+
.eq(&self.block_hash())
405+
|| height == 91812
406+
&& "00000000000af0aed4792b1acee3d966af36cf5def14935db8de83d6f9306f2f"
407+
.parse::<BlockHash>()
408+
.unwrap()
409+
.eq(&self.block_hash())
410+
}
411+
}

0 commit comments

Comments
 (0)