- 'outer_loop: for funding_generation in pending_funding_generation.drain(..) {
- let mut tx = Transaction { version: 0, lock_time: LockTime::ZERO, input: Vec::new(), output: vec![TxOut {
- value: funding_generation.2, script_pubkey: funding_generation.3,
- }] };
- let funding_output = 'search_loop: loop {
- let funding_txid = tx.txid();
- if let None = loss_detector.txids_confirmed.get(&funding_txid) {
- let outpoint = OutPoint { txid: funding_txid, index: 0 };
- for chan in channelmanager.list_channels() {
- if chan.funding_txo == Some(outpoint) {
- tx.version += 1;
- continue 'search_loop;
- }
+ let mut tx = Transaction { version: 0, lock_time: LockTime::ZERO, input: Vec::new(), output: Vec::new() };
+ let mut channels = Vec::new();
+ for funding_generation in pending_funding_generation.drain(..) {
+ let txout = TxOut {
+ value: funding_generation.2, script_pubkey: funding_generation.3,
+ };
+ if !tx.output.contains(&txout) {
+ tx.output.push(txout);
+ channels.push((funding_generation.0, funding_generation.1));
+ }
+ }
+ // Once we switch to V2 channel opens we should be able to drop this entirely as
+ // channel_ids no longer change when we set the funding tx.
+ 'search_loop: loop {
+ if tx.version > 0xff {
+ break;
+ }
+ let funding_txid = tx.txid();
+ if loss_detector.txids_confirmed.get(&funding_txid).is_none() {
+ let outpoint = OutPoint { txid: funding_txid, index: 0 };
+ for chan in channelmanager.list_channels() {
+ if chan.channel_id == ChannelId::v1_from_funding_outpoint(outpoint) {
+ tx.version += 1;
+ continue 'search_loop;