@@ -4,7 +4,6 @@ use bitcoin::blockdata::constants::genesis_block;
4
4
use bitcoin:: network:: constants:: Network ;
5
5
use bitcoin:: network:: serialize:: BitcoinHash ;
6
6
use bitcoin:: util:: hash:: Sha256dHash ;
7
- use bitcoin:: util:: uint:: Uint256 ;
8
7
9
8
use secp256k1:: key:: { SecretKey , PublicKey } ;
10
9
use secp256k1:: { Secp256k1 , Message } ;
@@ -111,16 +110,16 @@ enum PendingOutboundHTLC {
111
110
const MIN_HTLC_RELAY_HOLDING_CELL_MILLIS : u32 = 50 ;
112
111
113
112
struct ChannelHolder {
114
- by_id : HashMap < Uint256 , Channel > ,
115
- short_to_id : HashMap < u64 , Uint256 > ,
113
+ by_id : HashMap < [ u8 ; 32 ] , Channel > ,
114
+ short_to_id : HashMap < u64 , [ u8 ; 32 ] > ,
116
115
next_forward : Instant ,
117
116
/// short channel id -> forward infos. Key of 0 means payments received
118
117
forward_htlcs : HashMap < u64 , Vec < PendingForwardHTLCInfo > > ,
119
118
claimable_htlcs : HashMap < [ u8 ; 32 ] , PendingOutboundHTLC > ,
120
119
}
121
120
struct MutChannelHolder < ' a > {
122
- by_id : & ' a mut HashMap < Uint256 , Channel > ,
123
- short_to_id : & ' a mut HashMap < u64 , Uint256 > ,
121
+ by_id : & ' a mut HashMap < [ u8 ; 32 ] , Channel > ,
122
+ short_to_id : & ' a mut HashMap < u64 , [ u8 ; 32 ] > ,
124
123
next_forward : & ' a mut Instant ,
125
124
/// short channel id -> forward infos. Key of 0 means payments received
126
125
forward_htlcs : & ' a mut HashMap < u64 , Vec < PendingForwardHTLCInfo > > ,
@@ -187,7 +186,7 @@ pub struct ChannelDetails {
187
186
/// thereafter this is the txid of the funding transaction xor the funding transaction output).
188
187
/// Note that this means this value is *not* persistent - it can change once during the
189
188
/// lifetime of the channel.
190
- pub channel_id : Uint256 ,
189
+ pub channel_id : [ u8 ; 32 ] ,
191
190
/// The position of the funding transaction in the chain. None if the funding transaction has
192
191
/// not yet been confirmed and the channel fully opened.
193
192
pub short_channel_id : Option < u64 > ,
@@ -297,7 +296,7 @@ impl ChannelManager {
297
296
/// Begins the process of closing a channel. After this call (plus some timeout), no new HTLCs
298
297
/// will be accepted on the given channel, and after additional timeout/the closing of all
299
298
/// pending HTLCs, the channel will be closed on chain.
300
- pub fn close_channel ( & self , channel_id : & Uint256 ) -> Result < msgs:: Shutdown , HandleError > {
299
+ pub fn close_channel ( & self , channel_id : & [ u8 ; 32 ] ) -> Result < msgs:: Shutdown , HandleError > {
301
300
let ( res, chan_option) = {
302
301
let mut channel_state_lock = self . channel_state . lock ( ) . unwrap ( ) ;
303
302
let channel_state = channel_state_lock. borrow_parts ( ) ;
@@ -676,10 +675,10 @@ impl ChannelManager {
676
675
677
676
/// Call this upon creation of a funding transaction for the given channel.
678
677
/// Panics if a funding transaction has already been provided for this channel.
679
- pub fn funding_transaction_generated ( & self , temporary_channel_id : & Uint256 , funding_txo : OutPoint ) {
678
+ pub fn funding_transaction_generated ( & self , temporary_channel_id : & [ u8 ; 32 ] , funding_txo : OutPoint ) {
680
679
let ( chan, msg, chan_monitor) = {
681
680
let mut channel_state = self . channel_state . lock ( ) . unwrap ( ) ;
682
- match channel_state. by_id . remove ( & temporary_channel_id) {
681
+ match channel_state. by_id . remove ( temporary_channel_id) {
683
682
Some ( mut chan) => {
684
683
match chan. get_outbound_funding_created ( funding_txo) {
685
684
Ok ( funding_msg) => {
@@ -1838,7 +1837,6 @@ mod tests {
1838
1837
1839
1838
use bitcoin:: util:: misc:: hex_bytes;
1840
1839
use bitcoin:: util:: hash:: Sha256dHash ;
1841
- use bitcoin:: util:: uint:: Uint256 ;
1842
1840
use bitcoin:: blockdata:: block:: { Block , BlockHeader } ;
1843
1841
use bitcoin:: blockdata:: transaction:: { Transaction , TxOut } ;
1844
1842
use bitcoin:: network:: constants:: Network ;
@@ -2030,7 +2028,7 @@ mod tests {
2030
2028
}
2031
2029
2032
2030
static mut CHAN_COUNT : u32 = 0 ;
2033
- fn create_chan_between_nodes ( node_a : & Node , node_b : & Node ) -> ( msgs:: ChannelAnnouncement , msgs:: ChannelUpdate , msgs:: ChannelUpdate , Uint256 , Transaction ) {
2031
+ fn create_chan_between_nodes ( node_a : & Node , node_b : & Node ) -> ( msgs:: ChannelAnnouncement , msgs:: ChannelUpdate , msgs:: ChannelUpdate , [ u8 ; 32 ] , Transaction ) {
2034
2032
node_a. node . create_channel ( node_b. node . get_our_node_id ( ) , 100000 , 42 ) . unwrap ( ) ;
2035
2033
2036
2034
let events_1 = node_a. node . get_and_clear_pending_events ( ) ;
@@ -2158,7 +2156,7 @@ mod tests {
2158
2156
( ( * announcement) . clone ( ) , ( * as_update) . clone ( ) , ( * bs_update) . clone ( ) , channel_id, tx)
2159
2157
}
2160
2158
2161
- fn create_announced_chan_between_nodes ( nodes : & Vec < Node > , a : usize , b : usize ) -> ( msgs:: ChannelUpdate , msgs:: ChannelUpdate , Uint256 , Transaction ) {
2159
+ fn create_announced_chan_between_nodes ( nodes : & Vec < Node > , a : usize , b : usize ) -> ( msgs:: ChannelUpdate , msgs:: ChannelUpdate , [ u8 ; 32 ] , Transaction ) {
2162
2160
let chan_announcement = create_chan_between_nodes ( & nodes[ a] , & nodes[ b] ) ;
2163
2161
for node in nodes {
2164
2162
assert ! ( node. router. handle_channel_announcement( & chan_announcement. 0 ) . unwrap( ) ) ;
@@ -2168,7 +2166,7 @@ mod tests {
2168
2166
( chan_announcement. 1 , chan_announcement. 2 , chan_announcement. 3 , chan_announcement. 4 )
2169
2167
}
2170
2168
2171
- fn close_channel ( outbound_node : & Node , inbound_node : & Node , channel_id : & Uint256 , funding_tx : Transaction , close_inbound_first : bool ) -> ( msgs:: ChannelUpdate , msgs:: ChannelUpdate ) {
2169
+ fn close_channel ( outbound_node : & Node , inbound_node : & Node , channel_id : & [ u8 ; 32 ] , funding_tx : Transaction , close_inbound_first : bool ) -> ( msgs:: ChannelUpdate , msgs:: ChannelUpdate ) {
2172
2170
let ( node_a, broadcaster_a) = if close_inbound_first { ( & inbound_node. node , & inbound_node. tx_broadcaster ) } else { ( & outbound_node. node , & outbound_node. tx_broadcaster ) } ;
2173
2171
let ( node_b, broadcaster_b) = if close_inbound_first { ( & outbound_node. node , & outbound_node. tx_broadcaster ) } else { ( & inbound_node. node , & inbound_node. tx_broadcaster ) } ;
2174
2172
let ( tx_a, tx_b) ;
@@ -2679,7 +2677,7 @@ mod tests {
2679
2677
2680
2678
#[ derive( PartialEq ) ]
2681
2679
enum HTLCType { NONE , TIMEOUT , SUCCESS }
2682
- fn test_txn_broadcast ( node : & Node , chan : & ( msgs:: ChannelUpdate , msgs:: ChannelUpdate , Uint256 , Transaction ) , commitment_tx : Option < Transaction > , has_htlc_tx : HTLCType ) -> Vec < Transaction > {
2680
+ fn test_txn_broadcast ( node : & Node , chan : & ( msgs:: ChannelUpdate , msgs:: ChannelUpdate , [ u8 ; 32 ] , Transaction ) , commitment_tx : Option < Transaction > , has_htlc_tx : HTLCType ) -> Vec < Transaction > {
2683
2681
let mut node_txn = node. tx_broadcaster . txn_broadcasted . lock ( ) . unwrap ( ) ;
2684
2682
assert ! ( node_txn. len( ) >= if commitment_tx. is_some( ) { 0 } else { 1 } + if has_htlc_tx == HTLCType :: NONE { 0 } else { 1 } ) ;
2685
2683
0 commit comments