@@ -167,7 +167,7 @@ macro_rules! secp_call {
167
167
match $res {
168
168
Ok ( key) => key,
169
169
//TODO: Make the err a parameter!
170
- Err ( _) => return Err ( HandleError { err: "Key error" , msg : None } )
170
+ Err ( _) => return Err ( HandleError { err: "Key error" , action : None } )
171
171
}
172
172
} ;
173
173
}
@@ -311,7 +311,7 @@ impl ChannelManager {
311
311
( res, Some ( chan_entry. remove_entry ( ) . 1 ) )
312
312
} else { ( res, None ) }
313
313
} ,
314
- hash_map:: Entry :: Vacant ( _) => return Err ( HandleError { err : "No such channel" , msg : None } )
314
+ hash_map:: Entry :: Vacant ( _) => return Err ( HandleError { err : "No such channel" , action : None } )
315
315
}
316
316
} ;
317
317
for payment_hash in res. 1 {
@@ -443,11 +443,11 @@ impl ChannelManager {
443
443
} ;
444
444
cur_value_msat += hop. fee_msat ;
445
445
if cur_value_msat >= 21000000 * 100000000 * 1000 {
446
- return Err ( HandleError { err : "Channel fees overflowed?!" , msg : None } ) ;
446
+ return Err ( HandleError { err : "Channel fees overflowed?!" , action : None } ) ;
447
447
}
448
448
cur_cltv += hop. cltv_expiry_delta as u32 ;
449
449
if cur_cltv >= 500000000 {
450
- return Err ( HandleError { err : "Channel CLTV overflowed?!" , msg : None } ) ;
450
+ return Err ( HandleError { err : "Channel CLTV overflowed?!" , action : None } ) ;
451
451
}
452
452
last_short_channel_id = hop. short_channel_id ;
453
453
}
@@ -576,7 +576,7 @@ impl ChannelManager {
576
576
/// only fails if the channel does not yet have an assigned short_id
577
577
fn get_channel_update ( & self , chan : & Channel ) -> Result < msgs:: ChannelUpdate , HandleError > {
578
578
let short_channel_id = match chan. get_short_channel_id ( ) {
579
- None => return Err ( HandleError { err : "Channel not yet established" , msg : None } ) ,
579
+ None => return Err ( HandleError { err : "Channel not yet established" , action : None } ) ,
580
580
Some ( id) => id,
581
581
} ;
582
582
@@ -609,12 +609,12 @@ impl ChannelManager {
609
609
/// May generate a SendHTLCs event on success, which should be relayed.
610
610
pub fn send_payment ( & self , route : Route , payment_hash : [ u8 ; 32 ] ) -> Result < ( ) , HandleError > {
611
611
if route. hops . len ( ) < 1 || route. hops . len ( ) > 20 {
612
- return Err ( HandleError { err : "Route didn't go anywhere/had bogus size" , msg : None } ) ;
612
+ return Err ( HandleError { err : "Route didn't go anywhere/had bogus size" , action : None } ) ;
613
613
}
614
614
let our_node_id = self . get_our_node_id ( ) ;
615
615
for ( idx, hop) in route. hops . iter ( ) . enumerate ( ) {
616
616
if idx != route. hops . len ( ) - 1 && hop. pubkey == our_node_id {
617
- return Err ( HandleError { err : "Route went through us but wasn't a simple rebalance loop to us" , msg : None } ) ;
617
+ return Err ( HandleError { err : "Route went through us but wasn't a simple rebalance loop to us" , action : None } ) ;
618
618
}
619
619
}
620
620
@@ -633,13 +633,13 @@ impl ChannelManager {
633
633
let ( first_hop_node_id, ( update_add, commitment_signed, chan_monitor) ) = {
634
634
let mut channel_state = self . channel_state . lock ( ) . unwrap ( ) ;
635
635
let id = match channel_state. short_to_id . get ( & route. hops . first ( ) . unwrap ( ) . short_channel_id ) {
636
- None => return Err ( HandleError { err : "No channel available with first hop!" , msg : None } ) ,
636
+ None => return Err ( HandleError { err : "No channel available with first hop!" , action : None } ) ,
637
637
Some ( id) => id. clone ( )
638
638
} ;
639
639
let res = {
640
640
let chan = channel_state. by_id . get_mut ( & id) . unwrap ( ) ;
641
641
if chan. get_their_node_id ( ) != route. hops . first ( ) . unwrap ( ) . pubkey {
642
- return Err ( HandleError { err : "Node ID mismatch on first hop!" , msg : None } ) ;
642
+ return Err ( HandleError { err : "Node ID mismatch on first hop!" , action : None } ) ;
643
643
}
644
644
chan. send_htlc_and_commit ( htlc_msat, payment_hash. clone ( ) , htlc_cltv, onion_packet) ?
645
645
} ;
@@ -1099,11 +1099,11 @@ impl ChannelMessageHandler for ChannelManager {
1099
1099
//TODO: Handle errors and close channel (or so)
1100
1100
fn handle_open_channel ( & self , their_node_id : & PublicKey , msg : & msgs:: OpenChannel ) -> Result < msgs:: AcceptChannel , HandleError > {
1101
1101
if msg. chain_hash != self . genesis_hash {
1102
- return Err ( HandleError { err : "Unknown genesis block hash" , msg : None } ) ;
1102
+ return Err ( HandleError { err : "Unknown genesis block hash" , action : None } ) ;
1103
1103
}
1104
1104
let mut channel_state = self . channel_state . lock ( ) . unwrap ( ) ;
1105
1105
if channel_state. by_id . contains_key ( & msg. temporary_channel_id ) {
1106
- return Err ( HandleError { err : "temporary_channel_id collision!" , msg : None } ) ;
1106
+ return Err ( HandleError { err : "temporary_channel_id collision!" , action : None } ) ;
1107
1107
}
1108
1108
1109
1109
let chan_keys = if cfg ! ( feature = "fuzztarget" ) {
@@ -1138,12 +1138,12 @@ impl ChannelMessageHandler for ChannelManager {
1138
1138
match channel_state. by_id . get_mut ( & msg. temporary_channel_id ) {
1139
1139
Some ( chan) => {
1140
1140
if chan. get_their_node_id ( ) != * their_node_id {
1141
- return Err ( HandleError { err : "Got a message for a channel from the wrong node!" , msg : None } )
1141
+ return Err ( HandleError { err : "Got a message for a channel from the wrong node!" , action : None } )
1142
1142
}
1143
1143
chan. accept_channel ( & msg) ?;
1144
1144
( chan. get_value_satoshis ( ) , chan. get_funding_redeemscript ( ) . to_v0_p2wsh ( ) , chan. get_user_id ( ) )
1145
1145
} ,
1146
- None => return Err ( HandleError { err : "Failed to find corresponding channel" , msg : None } )
1146
+ None => return Err ( HandleError { err : "Failed to find corresponding channel" , action : None } )
1147
1147
}
1148
1148
} ;
1149
1149
let mut pending_events = self . pending_events . lock ( ) . unwrap ( ) ;
@@ -1165,7 +1165,7 @@ impl ChannelMessageHandler for ChannelManager {
1165
1165
match channel_state. by_id . remove ( & msg. temporary_channel_id ) {
1166
1166
Some ( mut chan) => {
1167
1167
if chan. get_their_node_id ( ) != * their_node_id {
1168
- return Err ( HandleError { err : "Got a message for a channel from the wrong node!" , msg : None } )
1168
+ return Err ( HandleError { err : "Got a message for a channel from the wrong node!" , action : None } )
1169
1169
}
1170
1170
match chan. funding_created ( msg) {
1171
1171
Ok ( ( funding_msg, monitor_update) ) => {
@@ -1176,7 +1176,7 @@ impl ChannelMessageHandler for ChannelManager {
1176
1176
}
1177
1177
}
1178
1178
} ,
1179
- None => return Err ( HandleError { err : "Failed to find corresponding channel" , msg : None } )
1179
+ None => return Err ( HandleError { err : "Failed to find corresponding channel" , action : None } )
1180
1180
}
1181
1181
} ; // Release channel lock for install_watch_outpoint call,
1182
1182
// note that this means if the remote end is misbehaving and sends a message for the same
@@ -1196,12 +1196,12 @@ impl ChannelMessageHandler for ChannelManager {
1196
1196
match channel_state. by_id . get_mut ( & msg. channel_id ) {
1197
1197
Some ( chan) => {
1198
1198
if chan. get_their_node_id ( ) != * their_node_id {
1199
- return Err ( HandleError { err : "Got a message for a channel from the wrong node!" , msg : None } )
1199
+ return Err ( HandleError { err : "Got a message for a channel from the wrong node!" , action : None } )
1200
1200
}
1201
1201
let chan_monitor = chan. funding_signed ( & msg) ?;
1202
1202
( chan. get_funding_txo ( ) . unwrap ( ) , chan. get_user_id ( ) , chan_monitor)
1203
1203
} ,
1204
- None => return Err ( HandleError { err : "Failed to find corresponding channel" , msg : None } )
1204
+ None => return Err ( HandleError { err : "Failed to find corresponding channel" , action : None } )
1205
1205
}
1206
1206
} ;
1207
1207
if let Err ( _e) = self . monitor . add_update_monitor ( monitor. get_funding_txo ( ) . unwrap ( ) , monitor) {
@@ -1220,12 +1220,12 @@ impl ChannelMessageHandler for ChannelManager {
1220
1220
match channel_state. by_id . get_mut ( & msg. channel_id ) {
1221
1221
Some ( chan) => {
1222
1222
if chan. get_their_node_id ( ) != * their_node_id {
1223
- return Err ( HandleError { err : "Got a message for a channel from the wrong node!" , msg : None } )
1223
+ return Err ( HandleError { err : "Got a message for a channel from the wrong node!" , action : None } )
1224
1224
}
1225
1225
chan. funding_locked ( & msg) ?;
1226
1226
return Ok ( self . get_announcement_sigs ( chan) ?) ;
1227
1227
} ,
1228
- None => return Err ( HandleError { err : "Failed to find corresponding channel" , msg : None } )
1228
+ None => return Err ( HandleError { err : "Failed to find corresponding channel" , action : None } )
1229
1229
} ;
1230
1230
}
1231
1231
@@ -1237,7 +1237,7 @@ impl ChannelMessageHandler for ChannelManager {
1237
1237
match channel_state. by_id . entry ( msg. channel_id . clone ( ) ) {
1238
1238
hash_map:: Entry :: Occupied ( mut chan_entry) => {
1239
1239
if chan_entry. get ( ) . get_their_node_id ( ) != * their_node_id {
1240
- return Err ( HandleError { err : "Got a message for a channel from the wrong node!" , msg : None } )
1240
+ return Err ( HandleError { err : "Got a message for a channel from the wrong node!" , action : None } )
1241
1241
}
1242
1242
let res = chan_entry. get_mut ( ) . shutdown ( & * self . fee_estimator , & msg) ?;
1243
1243
if chan_entry. get ( ) . is_shutdown ( ) {
@@ -1247,7 +1247,7 @@ impl ChannelMessageHandler for ChannelManager {
1247
1247
( res, Some ( chan_entry. remove_entry ( ) . 1 ) )
1248
1248
} else { ( res, None ) }
1249
1249
} ,
1250
- hash_map:: Entry :: Vacant ( _) => return Err ( HandleError { err : "Failed to find corresponding channel" , msg : None } )
1250
+ hash_map:: Entry :: Vacant ( _) => return Err ( HandleError { err : "Failed to find corresponding channel" , action : None } )
1251
1251
}
1252
1252
} ;
1253
1253
for payment_hash in res. 2 {
@@ -1272,7 +1272,7 @@ impl ChannelMessageHandler for ChannelManager {
1272
1272
match channel_state. by_id . entry ( msg. channel_id . clone ( ) ) {
1273
1273
hash_map:: Entry :: Occupied ( mut chan_entry) => {
1274
1274
if chan_entry. get ( ) . get_their_node_id ( ) != * their_node_id {
1275
- return Err ( HandleError { err : "Got a message for a channel from the wrong node!" , msg : None } )
1275
+ return Err ( HandleError { err : "Got a message for a channel from the wrong node!" , action : None } )
1276
1276
}
1277
1277
let res = chan_entry. get_mut ( ) . closing_signed ( & * self . fee_estimator , & msg) ?;
1278
1278
if res. 1 . is_some ( ) {
@@ -1287,7 +1287,7 @@ impl ChannelMessageHandler for ChannelManager {
1287
1287
( res, Some ( chan_entry. remove_entry ( ) . 1 ) )
1288
1288
} else { ( res, None ) }
1289
1289
} ,
1290
- hash_map:: Entry :: Vacant ( _) => return Err ( HandleError { err : "Failed to find corresponding channel" , msg : None } )
1290
+ hash_map:: Entry :: Vacant ( _) => return Err ( HandleError { err : "Failed to find corresponding channel" , action : None } )
1291
1291
}
1292
1292
} ;
1293
1293
if let Some ( broadcast_tx) = res. 1 {
@@ -1335,7 +1335,7 @@ impl ChannelMessageHandler for ChannelManager {
1335
1335
( $msg: expr, $err_code: expr, $data: expr) => {
1336
1336
return Err ( msgs:: HandleError {
1337
1337
err: $msg,
1338
- msg : Some ( msgs:: ErrorAction :: UpdateFailHTLC {
1338
+ action : Some ( msgs:: ErrorAction :: UpdateFailHTLC {
1339
1339
msg: msgs:: UpdateFailHTLC {
1340
1340
channel_id: msg. channel_id,
1341
1341
htlc_id: msg. htlc_id,
@@ -1494,16 +1494,16 @@ impl ChannelMessageHandler for ChannelManager {
1494
1494
let ( source_short_channel_id, res) = match channel_state. by_id . get_mut ( & msg. channel_id ) {
1495
1495
Some ( chan) => {
1496
1496
if chan. get_their_node_id ( ) != * their_node_id {
1497
- return Err ( HandleError { err : "Got a message for a channel from the wrong node!" , msg : None } )
1497
+ return Err ( HandleError { err : "Got a message for a channel from the wrong node!" , action : None } )
1498
1498
}
1499
1499
if !chan. is_usable ( ) {
1500
- return Err ( HandleError { err : "Channel not yet available for receiving HTLCs" , msg : None } ) ;
1500
+ return Err ( HandleError { err : "Channel not yet available for receiving HTLCs" , action : None } ) ;
1501
1501
}
1502
1502
let short_channel_id = chan. get_short_channel_id ( ) . unwrap ( ) ;
1503
1503
pending_forward_info. prev_short_channel_id = short_channel_id;
1504
1504
( short_channel_id, chan. update_add_htlc ( & msg, pending_forward_info) ?)
1505
1505
} ,
1506
- None => return Err ( HandleError { err : "Failed to find corresponding channel" , msg : None } ) , //TODO: panic?
1506
+ None => return Err ( HandleError { err : "Failed to find corresponding channel" , action : None } ) , //TODO: panic?
1507
1507
} ;
1508
1508
1509
1509
match claimable_htlcs_entry {
@@ -1544,11 +1544,11 @@ impl ChannelMessageHandler for ChannelManager {
1544
1544
match channel_state. by_id . get_mut ( & msg. channel_id ) {
1545
1545
Some ( chan) => {
1546
1546
if chan. get_their_node_id ( ) != * their_node_id {
1547
- return Err ( HandleError { err : "Got a message for a channel from the wrong node!" , msg : None } )
1547
+ return Err ( HandleError { err : "Got a message for a channel from the wrong node!" , action : None } )
1548
1548
}
1549
1549
chan. update_fulfill_htlc ( & msg) ?
1550
1550
} ,
1551
- None => return Err ( HandleError { err : "Failed to find corresponding channel" , msg : None } )
1551
+ None => return Err ( HandleError { err : "Failed to find corresponding channel" , action : None } )
1552
1552
}
1553
1553
} ;
1554
1554
if let Err ( _e) = self . monitor . add_update_monitor ( monitor. get_funding_txo ( ) . unwrap ( ) , monitor) {
@@ -1562,11 +1562,11 @@ impl ChannelMessageHandler for ChannelManager {
1562
1562
let payment_hash = match channel_state. by_id . get_mut ( & msg. channel_id ) {
1563
1563
Some ( chan) => {
1564
1564
if chan. get_their_node_id ( ) != * their_node_id {
1565
- return Err ( HandleError { err : "Got a message for a channel from the wrong node!" , msg : None } )
1565
+ return Err ( HandleError { err : "Got a message for a channel from the wrong node!" , action : None } )
1566
1566
}
1567
1567
chan. update_fail_htlc ( & msg, HTLCFailReason :: ErrorPacket { err : msg. reason . clone ( ) } )
1568
1568
} ,
1569
- None => return Err ( HandleError { err : "Failed to find corresponding channel" , msg : None } )
1569
+ None => return Err ( HandleError { err : "Failed to find corresponding channel" , action : None } )
1570
1570
} ?;
1571
1571
1572
1572
if let Some ( pending_htlc) = channel_state. claimable_htlcs . get ( & payment_hash) {
@@ -1637,11 +1637,11 @@ impl ChannelMessageHandler for ChannelManager {
1637
1637
match channel_state. by_id . get_mut ( & msg. channel_id ) {
1638
1638
Some ( chan) => {
1639
1639
if chan. get_their_node_id ( ) != * their_node_id {
1640
- return Err ( HandleError { err : "Got a message for a channel from the wrong node!" , msg : None } )
1640
+ return Err ( HandleError { err : "Got a message for a channel from the wrong node!" , action : None } )
1641
1641
}
1642
1642
chan. update_fail_malformed_htlc ( & msg, HTLCFailReason :: Reason { failure_code : msg. failure_code , data : Vec :: new ( ) } )
1643
1643
} ,
1644
- None => return Err ( HandleError { err : "Failed to find corresponding channel" , msg : None } )
1644
+ None => return Err ( HandleError { err : "Failed to find corresponding channel" , action : None } )
1645
1645
}
1646
1646
}
1647
1647
@@ -1651,11 +1651,11 @@ impl ChannelMessageHandler for ChannelManager {
1651
1651
match channel_state. by_id . get_mut ( & msg. channel_id ) {
1652
1652
Some ( chan) => {
1653
1653
if chan. get_their_node_id ( ) != * their_node_id {
1654
- return Err ( HandleError { err : "Got a message for a channel from the wrong node!" , msg : None } )
1654
+ return Err ( HandleError { err : "Got a message for a channel from the wrong node!" , action : None } )
1655
1655
}
1656
1656
chan. commitment_signed ( & msg) ?
1657
1657
} ,
1658
- None => return Err ( HandleError { err : "Failed to find corresponding channel" , msg : None } )
1658
+ None => return Err ( HandleError { err : "Failed to find corresponding channel" , action : None } )
1659
1659
}
1660
1660
} ;
1661
1661
if let Err ( _e) = self . monitor . add_update_monitor ( chan_monitor. get_funding_txo ( ) . unwrap ( ) , chan_monitor) {
@@ -1671,11 +1671,11 @@ impl ChannelMessageHandler for ChannelManager {
1671
1671
match channel_state. by_id . get_mut ( & msg. channel_id ) {
1672
1672
Some ( chan) => {
1673
1673
if chan. get_their_node_id ( ) != * their_node_id {
1674
- return Err ( HandleError { err : "Got a message for a channel from the wrong node!" , msg : None } )
1674
+ return Err ( HandleError { err : "Got a message for a channel from the wrong node!" , action : None } )
1675
1675
}
1676
1676
chan. revoke_and_ack ( & msg) ?
1677
1677
} ,
1678
- None => return Err ( HandleError { err : "Failed to find corresponding channel" , msg : None } )
1678
+ None => return Err ( HandleError { err : "Failed to find corresponding channel" , action : None } )
1679
1679
}
1680
1680
} ;
1681
1681
if let Err ( _e) = self . monitor . add_update_monitor ( chan_monitor. get_funding_txo ( ) . unwrap ( ) , chan_monitor) {
@@ -1721,11 +1721,11 @@ impl ChannelMessageHandler for ChannelManager {
1721
1721
match channel_state. by_id . get_mut ( & msg. channel_id ) {
1722
1722
Some ( chan) => {
1723
1723
if chan. get_their_node_id ( ) != * their_node_id {
1724
- return Err ( HandleError { err : "Got a message for a channel from the wrong node!" , msg : None } )
1724
+ return Err ( HandleError { err : "Got a message for a channel from the wrong node!" , action : None } )
1725
1725
}
1726
1726
chan. update_fee ( & * self . fee_estimator , & msg)
1727
1727
} ,
1728
- None => return Err ( HandleError { err : "Failed to find corresponding channel" , msg : None } )
1728
+ None => return Err ( HandleError { err : "Failed to find corresponding channel" , action : None } )
1729
1729
}
1730
1730
}
1731
1731
@@ -1735,10 +1735,10 @@ impl ChannelMessageHandler for ChannelManager {
1735
1735
match channel_state. by_id . get_mut ( & msg. channel_id ) {
1736
1736
Some ( chan) => {
1737
1737
if chan. get_their_node_id ( ) != * their_node_id {
1738
- return Err ( HandleError { err : "Got a message for a channel from the wrong node!" , msg : None } )
1738
+ return Err ( HandleError { err : "Got a message for a channel from the wrong node!" , action : None } )
1739
1739
}
1740
1740
if !chan. is_usable ( ) {
1741
- return Err ( HandleError { err : "Got an announcement_signatures before we were ready for it" , msg : None } ) ;
1741
+ return Err ( HandleError { err : "Got an announcement_signatures before we were ready for it" , action : None } ) ;
1742
1742
}
1743
1743
1744
1744
let our_node_id = self . get_our_node_id ( ) ;
@@ -1759,7 +1759,7 @@ impl ChannelMessageHandler for ChannelManager {
1759
1759
contents : announcement,
1760
1760
} , self . get_channel_update ( chan) . unwrap ( ) ) // can only fail if we're not in a ready state
1761
1761
} ,
1762
- None => return Err ( HandleError { err : "Failed to find corresponding channel" , msg : None } )
1762
+ None => return Err ( HandleError { err : "Failed to find corresponding channel" , action : None } )
1763
1763
}
1764
1764
} ;
1765
1765
let mut pending_events = self . pending_events . lock ( ) . unwrap ( ) ;
0 commit comments