@@ -629,33 +629,46 @@ pub fn do_test(mut data: &[u8], logger: &Arc<dyn Logger>) {
629
629
}
630
630
} ,
631
631
10 => {
632
- ' outer_loop: for funding_generation in pending_funding_generation. drain ( ..) {
633
- let mut tx = Transaction { version : 0 , lock_time : LockTime :: ZERO , input : Vec :: new ( ) , output : vec ! [ TxOut {
634
- value: funding_generation. 2 , script_pubkey: funding_generation. 3 ,
635
- } ] } ;
636
- let funding_output = ' search_loop: loop {
637
- let funding_txid = tx. txid ( ) ;
638
- if let None = loss_detector. txids_confirmed . get ( & funding_txid) {
639
- let outpoint = OutPoint { txid : funding_txid, index : 0 } ;
640
- for chan in channelmanager. list_channels ( ) {
641
- if chan. funding_txo == Some ( outpoint) {
642
- tx. version += 1 ;
643
- continue ' search_loop;
644
- }
632
+ let mut tx = Transaction { version : 0 , lock_time : LockTime :: ZERO , input : Vec :: new ( ) , output : Vec :: new ( ) } ;
633
+ let mut channels = Vec :: new ( ) ;
634
+ for funding_generation in pending_funding_generation. drain ( ..) {
635
+ let txout = TxOut {
636
+ value : funding_generation. 2 , script_pubkey : funding_generation. 3 ,
637
+ } ;
638
+ if !tx. output . contains ( & txout) {
639
+ tx. output . push ( txout) ;
640
+ channels. push ( ( funding_generation. 0 , funding_generation. 1 ) ) ;
641
+ }
642
+ }
643
+ ' search_loop: loop {
644
+ if tx. version > 0xff {
645
+ break ;
646
+ }
647
+ let funding_txid = tx. txid ( ) ;
648
+ if loss_detector. txids_confirmed . get ( & funding_txid) . is_none ( ) {
649
+ let outpoint = OutPoint { txid : funding_txid, index : 0 } ;
650
+ for chan in channelmanager. list_channels ( ) {
651
+ if chan. channel_id == outpoint. to_channel_id ( ) {
652
+ tx. version += 1 ;
653
+ continue ' search_loop;
645
654
}
646
- break outpoint;
647
- }
648
- tx. version += 1 ;
649
- if tx. version > 0xff {
650
- continue ' outer_loop;
651
655
}
652
- } ;
653
- if let Err ( e) = channelmanager. funding_transaction_generated ( & funding_generation. 0 , & funding_generation. 1 , tx. clone ( ) ) {
656
+ break ;
657
+ }
658
+ tx. version += 1 ;
659
+ }
660
+ if tx. version <= 0xff && !channels. is_empty ( ) {
661
+ let chans = channels. iter ( ) . map ( |( a, b) | ( a, b) ) . collect :: < Vec < _ > > ( ) ;
662
+ if let Err ( e) = channelmanager. batch_funding_transaction_generated ( & chans, tx. clone ( ) ) {
654
663
// It's possible the channel has been closed in the mean time, but any other
655
664
// failure may be a bug.
656
665
if let APIError :: ChannelUnavailable { .. } = e { } else { panic ! ( ) ; }
657
666
}
658
- pending_funding_signatures. insert ( funding_output, tx) ;
667
+ let funding_txid = tx. txid ( ) ;
668
+ for idx in 0 ..tx. output . len ( ) {
669
+ let outpoint = OutPoint { txid : funding_txid, index : idx as u16 } ;
670
+ pending_funding_signatures. insert ( outpoint, tx. clone ( ) ) ;
671
+ }
659
672
}
660
673
} ,
661
674
11 => {
0 commit comments