@@ -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
} ;
@@ -1111,11 +1111,11 @@ impl ChannelMessageHandler for ChannelManager {
1111
1111
//TODO: Handle errors and close channel (or so)
1112
1112
fn handle_open_channel ( & self , their_node_id : & PublicKey , msg : & msgs:: OpenChannel ) -> Result < msgs:: AcceptChannel , HandleError > {
1113
1113
if msg. chain_hash != self . genesis_hash {
1114
- return Err ( HandleError { err : "Unknown genesis block hash" , msg : None } ) ;
1114
+ return Err ( HandleError { err : "Unknown genesis block hash" , action : None } ) ;
1115
1115
}
1116
1116
let mut channel_state = self . channel_state . lock ( ) . unwrap ( ) ;
1117
1117
if channel_state. by_id . contains_key ( & msg. temporary_channel_id ) {
1118
- return Err ( HandleError { err : "temporary_channel_id collision!" , msg : None } ) ;
1118
+ return Err ( HandleError { err : "temporary_channel_id collision!" , action : None } ) ;
1119
1119
}
1120
1120
1121
1121
let chan_keys = if cfg ! ( feature = "fuzztarget" ) {
@@ -1150,12 +1150,12 @@ impl ChannelMessageHandler for ChannelManager {
1150
1150
match channel_state. by_id . get_mut ( & msg. temporary_channel_id ) {
1151
1151
Some ( chan) => {
1152
1152
if chan. get_their_node_id ( ) != * their_node_id {
1153
- return Err ( HandleError { err : "Got a message for a channel from the wrong node!" , msg : None } )
1153
+ return Err ( HandleError { err : "Got a message for a channel from the wrong node!" , action : None } )
1154
1154
}
1155
1155
chan. accept_channel ( & msg) ?;
1156
1156
( chan. get_value_satoshis ( ) , chan. get_funding_redeemscript ( ) . to_v0_p2wsh ( ) , chan. get_user_id ( ) )
1157
1157
} ,
1158
- None => return Err ( HandleError { err : "Failed to find corresponding channel" , msg : None } )
1158
+ None => return Err ( HandleError { err : "Failed to find corresponding channel" , action : None } )
1159
1159
}
1160
1160
} ;
1161
1161
let mut pending_events = self . pending_events . lock ( ) . unwrap ( ) ;
@@ -1177,7 +1177,7 @@ impl ChannelMessageHandler for ChannelManager {
1177
1177
match channel_state. by_id . remove ( & msg. temporary_channel_id ) {
1178
1178
Some ( mut chan) => {
1179
1179
if chan. get_their_node_id ( ) != * their_node_id {
1180
- return Err ( HandleError { err : "Got a message for a channel from the wrong node!" , msg : None } )
1180
+ return Err ( HandleError { err : "Got a message for a channel from the wrong node!" , action : None } )
1181
1181
}
1182
1182
match chan. funding_created ( msg) {
1183
1183
Ok ( ( funding_msg, monitor_update) ) => {
@@ -1188,7 +1188,7 @@ impl ChannelMessageHandler for ChannelManager {
1188
1188
}
1189
1189
}
1190
1190
} ,
1191
- None => return Err ( HandleError { err : "Failed to find corresponding channel" , msg : None } )
1191
+ None => return Err ( HandleError { err : "Failed to find corresponding channel" , action : None } )
1192
1192
}
1193
1193
} ; // Release channel lock for install_watch_outpoint call,
1194
1194
// note that this means if the remote end is misbehaving and sends a message for the same
@@ -1208,12 +1208,12 @@ impl ChannelMessageHandler for ChannelManager {
1208
1208
match channel_state. by_id . get_mut ( & msg. channel_id ) {
1209
1209
Some ( chan) => {
1210
1210
if chan. get_their_node_id ( ) != * their_node_id {
1211
- return Err ( HandleError { err : "Got a message for a channel from the wrong node!" , msg : None } )
1211
+ return Err ( HandleError { err : "Got a message for a channel from the wrong node!" , action : None } )
1212
1212
}
1213
1213
let chan_monitor = chan. funding_signed ( & msg) ?;
1214
1214
( chan. get_funding_txo ( ) . unwrap ( ) , chan. get_user_id ( ) , chan_monitor)
1215
1215
} ,
1216
- None => return Err ( HandleError { err : "Failed to find corresponding channel" , msg : None } )
1216
+ None => return Err ( HandleError { err : "Failed to find corresponding channel" , action : None } )
1217
1217
}
1218
1218
} ;
1219
1219
if let Err ( _e) = self . monitor . add_update_monitor ( monitor. get_funding_txo ( ) . unwrap ( ) , monitor) {
@@ -1232,12 +1232,12 @@ impl ChannelMessageHandler for ChannelManager {
1232
1232
match channel_state. by_id . get_mut ( & msg. channel_id ) {
1233
1233
Some ( chan) => {
1234
1234
if chan. get_their_node_id ( ) != * their_node_id {
1235
- return Err ( HandleError { err : "Got a message for a channel from the wrong node!" , msg : None } )
1235
+ return Err ( HandleError { err : "Got a message for a channel from the wrong node!" , action : None } )
1236
1236
}
1237
1237
chan. funding_locked ( & msg) ?;
1238
1238
return Ok ( self . get_announcement_sigs ( chan) ?) ;
1239
1239
} ,
1240
- None => return Err ( HandleError { err : "Failed to find corresponding channel" , msg : None } )
1240
+ None => return Err ( HandleError { err : "Failed to find corresponding channel" , action : None } )
1241
1241
} ;
1242
1242
}
1243
1243
@@ -1249,7 +1249,7 @@ impl ChannelMessageHandler for ChannelManager {
1249
1249
match channel_state. by_id . entry ( msg. channel_id . clone ( ) ) {
1250
1250
hash_map:: Entry :: Occupied ( mut chan_entry) => {
1251
1251
if chan_entry. get ( ) . get_their_node_id ( ) != * their_node_id {
1252
- return Err ( HandleError { err : "Got a message for a channel from the wrong node!" , msg : None } )
1252
+ return Err ( HandleError { err : "Got a message for a channel from the wrong node!" , action : None } )
1253
1253
}
1254
1254
let res = chan_entry. get_mut ( ) . shutdown ( & * self . fee_estimator , & msg) ?;
1255
1255
if chan_entry. get ( ) . is_shutdown ( ) {
@@ -1259,7 +1259,7 @@ impl ChannelMessageHandler for ChannelManager {
1259
1259
( res, Some ( chan_entry. remove_entry ( ) . 1 ) )
1260
1260
} else { ( res, None ) }
1261
1261
} ,
1262
- hash_map:: Entry :: Vacant ( _) => return Err ( HandleError { err : "Failed to find corresponding channel" , msg : None } )
1262
+ hash_map:: Entry :: Vacant ( _) => return Err ( HandleError { err : "Failed to find corresponding channel" , action : None } )
1263
1263
}
1264
1264
} ;
1265
1265
for payment_hash in res. 2 {
@@ -1284,7 +1284,7 @@ impl ChannelMessageHandler for ChannelManager {
1284
1284
match channel_state. by_id . entry ( msg. channel_id . clone ( ) ) {
1285
1285
hash_map:: Entry :: Occupied ( mut chan_entry) => {
1286
1286
if chan_entry. get ( ) . get_their_node_id ( ) != * their_node_id {
1287
- return Err ( HandleError { err : "Got a message for a channel from the wrong node!" , msg : None } )
1287
+ return Err ( HandleError { err : "Got a message for a channel from the wrong node!" , action : None } )
1288
1288
}
1289
1289
let res = chan_entry. get_mut ( ) . closing_signed ( & * self . fee_estimator , & msg) ?;
1290
1290
if res. 1 . is_some ( ) {
@@ -1299,7 +1299,7 @@ impl ChannelMessageHandler for ChannelManager {
1299
1299
( res, Some ( chan_entry. remove_entry ( ) . 1 ) )
1300
1300
} else { ( res, None ) }
1301
1301
} ,
1302
- hash_map:: Entry :: Vacant ( _) => return Err ( HandleError { err : "Failed to find corresponding channel" , msg : None } )
1302
+ hash_map:: Entry :: Vacant ( _) => return Err ( HandleError { err : "Failed to find corresponding channel" , action : None } )
1303
1303
}
1304
1304
} ;
1305
1305
if let Some ( broadcast_tx) = res. 1 {
@@ -1347,7 +1347,7 @@ impl ChannelMessageHandler for ChannelManager {
1347
1347
( $msg: expr, $err_code: expr, $data: expr) => {
1348
1348
return Err ( msgs:: HandleError {
1349
1349
err: $msg,
1350
- msg : Some ( msgs:: ErrorAction :: UpdateFailHTLC {
1350
+ action : Some ( msgs:: ErrorAction :: UpdateFailHTLC {
1351
1351
msg: msgs:: UpdateFailHTLC {
1352
1352
channel_id: msg. channel_id,
1353
1353
htlc_id: msg. htlc_id,
@@ -1506,16 +1506,16 @@ impl ChannelMessageHandler for ChannelManager {
1506
1506
let ( source_short_channel_id, res) = match channel_state. by_id . get_mut ( & msg. channel_id ) {
1507
1507
Some ( chan) => {
1508
1508
if chan. get_their_node_id ( ) != * their_node_id {
1509
- return Err ( HandleError { err : "Got a message for a channel from the wrong node!" , msg : None } )
1509
+ return Err ( HandleError { err : "Got a message for a channel from the wrong node!" , action : None } )
1510
1510
}
1511
1511
if !chan. is_usable ( ) {
1512
- return Err ( HandleError { err : "Channel not yet available for receiving HTLCs" , msg : None } ) ;
1512
+ return Err ( HandleError { err : "Channel not yet available for receiving HTLCs" , action : None } ) ;
1513
1513
}
1514
1514
let short_channel_id = chan. get_short_channel_id ( ) . unwrap ( ) ;
1515
1515
pending_forward_info. prev_short_channel_id = short_channel_id;
1516
1516
( short_channel_id, chan. update_add_htlc ( & msg, pending_forward_info) ?)
1517
1517
} ,
1518
- None => return Err ( HandleError { err : "Failed to find corresponding channel" , msg : None } ) , //TODO: panic?
1518
+ None => return Err ( HandleError { err : "Failed to find corresponding channel" , action : None } ) , //TODO: panic?
1519
1519
} ;
1520
1520
1521
1521
match claimable_htlcs_entry {
@@ -1556,11 +1556,11 @@ impl ChannelMessageHandler for ChannelManager {
1556
1556
match channel_state. by_id . get_mut ( & msg. channel_id ) {
1557
1557
Some ( chan) => {
1558
1558
if chan. get_their_node_id ( ) != * their_node_id {
1559
- return Err ( HandleError { err : "Got a message for a channel from the wrong node!" , msg : None } )
1559
+ return Err ( HandleError { err : "Got a message for a channel from the wrong node!" , action : None } )
1560
1560
}
1561
1561
chan. update_fulfill_htlc ( & msg) ?
1562
1562
} ,
1563
- None => return Err ( HandleError { err : "Failed to find corresponding channel" , msg : None } )
1563
+ None => return Err ( HandleError { err : "Failed to find corresponding channel" , action : None } )
1564
1564
}
1565
1565
} ;
1566
1566
if let Err ( _e) = self . monitor . add_update_monitor ( monitor. get_funding_txo ( ) . unwrap ( ) , monitor) {
@@ -1574,11 +1574,11 @@ impl ChannelMessageHandler for ChannelManager {
1574
1574
let payment_hash = match channel_state. by_id . get_mut ( & msg. channel_id ) {
1575
1575
Some ( chan) => {
1576
1576
if chan. get_their_node_id ( ) != * their_node_id {
1577
- return Err ( HandleError { err : "Got a message for a channel from the wrong node!" , msg : None } )
1577
+ return Err ( HandleError { err : "Got a message for a channel from the wrong node!" , action : None } )
1578
1578
}
1579
1579
chan. update_fail_htlc ( & msg, HTLCFailReason :: ErrorPacket { err : msg. reason . clone ( ) } )
1580
1580
} ,
1581
- None => return Err ( HandleError { err : "Failed to find corresponding channel" , msg : None } )
1581
+ None => return Err ( HandleError { err : "Failed to find corresponding channel" , action : None } )
1582
1582
} ?;
1583
1583
1584
1584
if let Some ( pending_htlc) = channel_state. claimable_htlcs . get ( & payment_hash) {
@@ -1649,11 +1649,11 @@ impl ChannelMessageHandler for ChannelManager {
1649
1649
match channel_state. by_id . get_mut ( & msg. channel_id ) {
1650
1650
Some ( chan) => {
1651
1651
if chan. get_their_node_id ( ) != * their_node_id {
1652
- return Err ( HandleError { err : "Got a message for a channel from the wrong node!" , msg : None } )
1652
+ return Err ( HandleError { err : "Got a message for a channel from the wrong node!" , action : None } )
1653
1653
}
1654
1654
chan. update_fail_malformed_htlc ( & msg, HTLCFailReason :: Reason { failure_code : msg. failure_code , data : Vec :: new ( ) } )
1655
1655
} ,
1656
- None => return Err ( HandleError { err : "Failed to find corresponding channel" , msg : None } )
1656
+ None => return Err ( HandleError { err : "Failed to find corresponding channel" , action : None } )
1657
1657
}
1658
1658
}
1659
1659
@@ -1663,11 +1663,11 @@ impl ChannelMessageHandler for ChannelManager {
1663
1663
match channel_state. by_id . get_mut ( & msg. channel_id ) {
1664
1664
Some ( chan) => {
1665
1665
if chan. get_their_node_id ( ) != * their_node_id {
1666
- return Err ( HandleError { err : "Got a message for a channel from the wrong node!" , msg : None } )
1666
+ return Err ( HandleError { err : "Got a message for a channel from the wrong node!" , action : None } )
1667
1667
}
1668
1668
chan. commitment_signed ( & msg) ?
1669
1669
} ,
1670
- None => return Err ( HandleError { err : "Failed to find corresponding channel" , msg : None } )
1670
+ None => return Err ( HandleError { err : "Failed to find corresponding channel" , action : None } )
1671
1671
}
1672
1672
} ;
1673
1673
if let Err ( _e) = self . monitor . add_update_monitor ( chan_monitor. get_funding_txo ( ) . unwrap ( ) , chan_monitor) {
@@ -1683,11 +1683,11 @@ impl ChannelMessageHandler for ChannelManager {
1683
1683
match channel_state. by_id . get_mut ( & msg. channel_id ) {
1684
1684
Some ( chan) => {
1685
1685
if chan. get_their_node_id ( ) != * their_node_id {
1686
- return Err ( HandleError { err : "Got a message for a channel from the wrong node!" , msg : None } )
1686
+ return Err ( HandleError { err : "Got a message for a channel from the wrong node!" , action : None } )
1687
1687
}
1688
1688
chan. revoke_and_ack ( & msg) ?
1689
1689
} ,
1690
- None => return Err ( HandleError { err : "Failed to find corresponding channel" , msg : None } )
1690
+ None => return Err ( HandleError { err : "Failed to find corresponding channel" , action : None } )
1691
1691
}
1692
1692
} ;
1693
1693
if let Err ( _e) = self . monitor . add_update_monitor ( chan_monitor. get_funding_txo ( ) . unwrap ( ) , chan_monitor) {
@@ -1733,11 +1733,11 @@ impl ChannelMessageHandler for ChannelManager {
1733
1733
match channel_state. by_id . get_mut ( & msg. channel_id ) {
1734
1734
Some ( chan) => {
1735
1735
if chan. get_their_node_id ( ) != * their_node_id {
1736
- return Err ( HandleError { err : "Got a message for a channel from the wrong node!" , msg : None } )
1736
+ return Err ( HandleError { err : "Got a message for a channel from the wrong node!" , action : None } )
1737
1737
}
1738
1738
chan. update_fee ( & * self . fee_estimator , & msg)
1739
1739
} ,
1740
- None => return Err ( HandleError { err : "Failed to find corresponding channel" , msg : None } )
1740
+ None => return Err ( HandleError { err : "Failed to find corresponding channel" , action : None } )
1741
1741
}
1742
1742
}
1743
1743
@@ -1747,10 +1747,10 @@ impl ChannelMessageHandler for ChannelManager {
1747
1747
match channel_state. by_id . get_mut ( & msg. channel_id ) {
1748
1748
Some ( chan) => {
1749
1749
if chan. get_their_node_id ( ) != * their_node_id {
1750
- return Err ( HandleError { err : "Got a message for a channel from the wrong node!" , msg : None } )
1750
+ return Err ( HandleError { err : "Got a message for a channel from the wrong node!" , action : None } )
1751
1751
}
1752
1752
if !chan. is_usable ( ) {
1753
- return Err ( HandleError { err : "Got an announcement_signatures before we were ready for it" , msg : None } ) ;
1753
+ return Err ( HandleError { err : "Got an announcement_signatures before we were ready for it" , action : None } ) ;
1754
1754
}
1755
1755
1756
1756
let our_node_id = self . get_our_node_id ( ) ;
@@ -1771,7 +1771,7 @@ impl ChannelMessageHandler for ChannelManager {
1771
1771
contents : announcement,
1772
1772
} , self . get_channel_update ( chan) . unwrap ( ) ) // can only fail if we're not in a ready state
1773
1773
} ,
1774
- None => return Err ( HandleError { err : "Failed to find corresponding channel" , msg : None } )
1774
+ None => return Err ( HandleError { err : "Failed to find corresponding channel" , action : None } )
1775
1775
}
1776
1776
} ;
1777
1777
let mut pending_events = self . pending_events . lock ( ) . unwrap ( ) ;
0 commit comments