Type Alias breez_sdk_liquid::lightning::chain::transaction::TransactionData

pub type TransactionData<'a> = [(usize, &'a Transaction)];
Expand description

Transaction data where each item consists of a transaction reference paired with the index of the transaction within a block.

Useful for passing enumerated transactions from a block, possibly filtered, in order to retain the transaction index.

extern crate bitcoin;
extern crate lightning;

use bitcoin::blockdata::block::Block;
use bitcoin::blockdata::constants::genesis_block;
use bitcoin::network::constants::Network;
use lightning::chain::transaction::TransactionData;

let block = genesis_block(Network::Bitcoin);
let txdata: Vec<_> = block.txdata.iter().enumerate().collect();
check_block(&block, &txdata);

fn check_block(block: &Block, txdata: &TransactionData) {
	assert_eq!(block.txdata.len(), 1);
	assert_eq!(txdata.len(), 1);

	let (index, tx) = txdata[0];
	assert_eq!(index, 0);
	assert_eq!(tx, &block.txdata[0]);
}