@@ -46,7 +46,7 @@ use alloc::rc::Rc;
46
46
use crate :: sync:: { Arc , Mutex , LockTestExt , RwLock } ;
47
47
use core:: mem;
48
48
use core:: iter:: repeat;
49
- use bitcoin:: { PackedLockTime , TxMerkleNode } ;
49
+ use bitcoin:: { PackedLockTime , TxIn , TxMerkleNode } ;
50
50
51
51
pub const CHAN_CONFIRM_DEPTH : u32 = 10 ;
52
52
@@ -1005,7 +1005,23 @@ macro_rules! reload_node {
1005
1005
} ;
1006
1006
}
1007
1007
1008
- pub fn create_funding_transaction < ' a , ' b , ' c > ( node : & Node < ' a , ' b , ' c > , expected_counterparty_node_id : & PublicKey , expected_chan_value : u64 , expected_user_chan_id : u128 ) -> ( ChannelId , Transaction , OutPoint ) {
1008
+ pub fn create_funding_transaction < ' a , ' b , ' c > ( node : & Node < ' a , ' b , ' c > ,
1009
+ expected_counterparty_node_id : & PublicKey , expected_chan_value : u64 , expected_user_chan_id : u128 )
1010
+ -> ( ChannelId , Transaction , OutPoint )
1011
+ {
1012
+ internal_create_funding_transaction ( node, expected_counterparty_node_id, expected_chan_value, expected_user_chan_id, false )
1013
+ }
1014
+
1015
+ pub fn create_coinbase_funding_transaction < ' a , ' b , ' c > ( node : & Node < ' a , ' b , ' c > ,
1016
+ expected_counterparty_node_id : & PublicKey , expected_chan_value : u64 , expected_user_chan_id : u128 )
1017
+ -> ( ChannelId , Transaction , OutPoint )
1018
+ {
1019
+ internal_create_funding_transaction ( node, expected_counterparty_node_id, expected_chan_value, expected_user_chan_id, true )
1020
+ }
1021
+
1022
+ fn internal_create_funding_transaction < ' a , ' b , ' c > ( node : & Node < ' a , ' b , ' c > ,
1023
+ expected_counterparty_node_id : & PublicKey , expected_chan_value : u64 , expected_user_chan_id : u128 ,
1024
+ coinbase : bool ) -> ( ChannelId , Transaction , OutPoint ) {
1009
1025
let chan_id = * node. network_chan_count . borrow ( ) ;
1010
1026
1011
1027
let events = node. node . get_and_clear_pending_events ( ) ;
@@ -1016,7 +1032,16 @@ pub fn create_funding_transaction<'a, 'b, 'c>(node: &Node<'a, 'b, 'c>, expected_
1016
1032
assert_eq ! ( * channel_value_satoshis, expected_chan_value) ;
1017
1033
assert_eq ! ( user_channel_id, expected_user_chan_id) ;
1018
1034
1019
- let tx = Transaction { version : chan_id as i32 , lock_time : PackedLockTime :: ZERO , input : Vec :: new ( ) , output : vec ! [ TxOut {
1035
+ let input = if coinbase {
1036
+ vec ! [ TxIn {
1037
+ previous_output: bitcoin:: OutPoint :: null( ) ,
1038
+ ..Default :: default ( )
1039
+ } ]
1040
+ } else {
1041
+ Vec :: new ( )
1042
+ } ;
1043
+
1044
+ let tx = Transaction { version : chan_id as i32 , lock_time : PackedLockTime :: ZERO , input, output : vec ! [ TxOut {
1020
1045
value: * channel_value_satoshis, script_pubkey: output_script. clone( ) ,
1021
1046
} ] } ;
1022
1047
let funding_outpoint = OutPoint { txid : tx. txid ( ) , index : 0 } ;
@@ -1025,6 +1050,7 @@ pub fn create_funding_transaction<'a, 'b, 'c>(node: &Node<'a, 'b, 'c>, expected_
1025
1050
_ => panic ! ( "Unexpected event" ) ,
1026
1051
}
1027
1052
}
1053
+
1028
1054
pub fn sign_funding_transaction < ' a , ' b , ' c > ( node_a : & Node < ' a , ' b , ' c > , node_b : & Node < ' a , ' b , ' c > , channel_value : u64 , expected_temporary_channel_id : ChannelId ) -> Transaction {
1029
1055
let ( temporary_channel_id, tx, funding_output) = create_funding_transaction ( node_a, & node_b. node . get_our_node_id ( ) , channel_value, 42 ) ;
1030
1056
assert_eq ! ( temporary_channel_id, expected_temporary_channel_id) ;
0 commit comments