Skip to content

Commit 03d67ec

Browse files
feat: adapt bindings to btck_api changes
- Rename BlockIndex to BlockTreeIndex - Add Chain instance - Introduce c_helpers for Rust/C type conversion
1 parent 27ceba6 commit 03d67ec

File tree

4 files changed

+393
-169
lines changed

4 files changed

+393
-169
lines changed

examples/src/silentpaymentscanner.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,13 +162,19 @@ fn scan_tx(receiver: &Receiver, secret_scan_key: &SecretKey, scan_tx_helper: Sca
162162

163163
fn scan_txs(chainman: &ChainstateManager) {
164164
let (receiver, secret_scan_key) = parse_keys();
165-
let mut block_index = chainman.block_index_tip();
165+
let chain = chainman.active_chain();
166+
let mut block_index = chain.tip();
167+
166168
loop {
167169
if block_index.height() <= 1 {
168170
break;
169171
}
170172
let spent_outputs = chainman.read_spent_outputs(&block_index).unwrap();
171-
let raw_block: Vec<u8> = chainman.read_block_data(&block_index).unwrap().into();
173+
let raw_block: Vec<u8> = chainman
174+
.read_block_data(&block_index)
175+
.unwrap()
176+
.try_into()
177+
.unwrap();
172178
let block: bitcoin::Block = deserialize(&raw_block).unwrap();
173179
// Should be the same size minus the coinbase transaction
174180
assert_eq!(block.txdata.len() - 1, spent_outputs.count());

fuzz/fuzz_targets/fuzz_target_block.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use libfuzzer_sys::fuzz_target;
55

66
fuzz_target!(|data: &[u8]| {
77
if let Ok(block) = Block::try_from(data) {
8-
let block_serialized: Vec<u8> = block.into();
8+
let block_serialized: Vec<u8> = block.try_into().unwrap();
99
assert!(data.len() >= block_serialized.len());
1010
}
1111
});

0 commit comments

Comments
 (0)