X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=src%2Fln%2Frouter.rs;h=bb20c31c35af9f868ee76c91933558b173130dc4;hb=4769b944de50f3819b4252353345009b1d810e90;hp=f4a702fb709387f859b5fe54c82457dc5229ded1;hpb=7a77c9f1d2297dc85dcf48aa898ae153440dbdc5;p=rust-lightning diff --git a/src/ln/router.rs b/src/ln/router.rs index f4a702fb..bb20c31c 100644 --- a/src/ln/router.rs +++ b/src/ln/router.rs @@ -7,7 +7,8 @@ use secp256k1::key::PublicKey; use secp256k1::Secp256k1; use secp256k1; -use bitcoin::util::hash::Sha256dHash; +use bitcoin_hashes::sha256d::Hash as Sha256dHash; +use bitcoin_hashes::Hash; use bitcoin::blockdata::script::Builder; use bitcoin::blockdata::opcodes; @@ -410,7 +411,7 @@ macro_rules! secp_verify_sig { impl RoutingMessageHandler for Router { fn handle_node_announcement(&self, msg: &msgs::NodeAnnouncement) -> Result { - let msg_hash = hash_to_message!(&Sha256dHash::from_data(&msg.contents.encode()[..])[..]); + let msg_hash = hash_to_message!(&Sha256dHash::hash(&msg.contents.encode()[..])[..]); secp_verify_sig!(self.secp_ctx, &msg_hash, &msg.signature, &msg.contents.node_id); if msg.contents.features.requires_unknown_bits() { @@ -443,7 +444,7 @@ impl RoutingMessageHandler for Router { return Err(HandleError{err: "Channel announcement node had a channel with itself", action: Some(ErrorAction::IgnoreError)}); } - let msg_hash = hash_to_message!(&Sha256dHash::from_data(&msg.contents.encode()[..])[..]); + let msg_hash = hash_to_message!(&Sha256dHash::hash(&msg.contents.encode()[..])[..]); secp_verify_sig!(self.secp_ctx, &msg_hash, &msg.node_signature_1, &msg.contents.node_id_1); secp_verify_sig!(self.secp_ctx, &msg_hash, &msg.node_signature_2, &msg.contents.node_id_2); secp_verify_sig!(self.secp_ctx, &msg_hash, &msg.bitcoin_signature_1, &msg.contents.bitcoin_key_1); @@ -512,7 +513,7 @@ impl RoutingMessageHandler for Router { match network.channels.entry(NetworkMap::get_key(msg.contents.short_channel_id, msg.contents.chain_hash)) { BtreeEntry::Occupied(mut entry) => { //TODO: because asking the blockchain if short_channel_id is valid is only optional - //in the blockchain API, we need to handle it smartly here, though its unclear + //in the blockchain API, we need to handle it smartly here, though it's unclear //exactly how... if checked_utxo { // Either our UTXO provider is busted, there was a reorg, or the UTXO provider @@ -619,7 +620,7 @@ impl RoutingMessageHandler for Router { }; } } - let msg_hash = hash_to_message!(&Sha256dHash::from_data(&msg.contents.encode()[..])[..]); + let msg_hash = hash_to_message!(&Sha256dHash::hash(&msg.contents.encode()[..])[..]); if msg.contents.flags & 1 == 1 { dest_node_id = channel.one_to_two.src_node_id.clone(); secp_verify_sig!(self.secp_ctx, &msg_hash, &msg.signature, &channel.two_to_one.src_node_id); @@ -779,7 +780,7 @@ impl Router { } /// Marks a node as having failed a route. This will avoid re-using the node in routes for now, - /// with an expotnential decay in node "badness". Note that there is deliberately no + /// with an exponential decay in node "badness". Note that there is deliberately no /// mark_channel_bad as a node may simply lie and suggest that an upstream channel from it is /// what failed the route and not the node itself. Instead, setting the blamed_upstream_node /// boolean will reduce the penalty, returning the node to usability faster. If the node is @@ -1020,7 +1021,8 @@ mod tests { use util::logger::Logger; use util::ser::{Writeable, Readable}; - use bitcoin::util::hash::Sha256dHash; + use bitcoin_hashes::sha256d::Hash as Sha256dHash; + use bitcoin_hashes::Hash; use bitcoin::network::constants::Network; use hex; @@ -1104,7 +1106,7 @@ mod tests { let node7 = PublicKey::from_secret_key(&secp_ctx, &SecretKey::from_slice(&hex::decode("0808080808080808080808080808080808080808080808080808080808080808").unwrap()[..]).unwrap()); let node8 = PublicKey::from_secret_key(&secp_ctx, &SecretKey::from_slice(&hex::decode("0909090909090909090909090909090909090909090909090909090909090909").unwrap()[..]).unwrap()); - let zero_hash = Sha256dHash::from_data(&[0; 32]); + let zero_hash = Sha256dHash::hash(&[0; 32]); { let mut network = router.network_map.write().unwrap(); @@ -1466,6 +1468,9 @@ mod tests { remote_network_id: node8.clone(), channel_value_satoshis: 0, user_id: 0, + outbound_capacity_msat: 0, + inbound_capacity_msat: 0, + is_live: true, }]; let route = router.get_route(&node3, Some(&our_chans), &Vec::new(), 100, 42).unwrap(); assert_eq!(route.hops.len(), 2); @@ -1541,6 +1546,9 @@ mod tests { remote_network_id: node4.clone(), channel_value_satoshis: 0, user_id: 0, + outbound_capacity_msat: 0, + inbound_capacity_msat: 0, + is_live: true, }]; let route = router.get_route(&node7, Some(&our_chans), &last_hops, 100, 42).unwrap(); assert_eq!(route.hops.len(), 2);