|
1 |
| -use bitcoin::blockdata::block::BlockHeader; |
2 |
| -use bitcoin::blockdata::transaction::Transaction; |
| 1 | + use bitcoin::blockdata::block::BlockHeader; |
| 2 | +use bitcoin::blockdata::transaction::{TxOutRef, Transaction}; |
3 | 3 | use bitcoin::blockdata::constants::genesis_block;
|
4 | 4 | use bitcoin::network::constants::Network;
|
5 | 5 | use bitcoin::network::serialize::BitcoinHash;
|
@@ -235,12 +235,12 @@ impl ChannelManager {
|
235 | 235 | pub fn create_channel(&self, their_network_key: PublicKey, channel_value_satoshis: u64, user_id: u64) -> Result<msgs::OpenChannel, HandleError> {
|
236 | 236 | let chan_keys = if cfg!(feature = "fuzztarget") {
|
237 | 237 | ChannelKeys {
|
238 |
| - funding_key: SecretKey::from_slice(&self.secp_ctx, &[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]).unwrap(), |
239 |
| - revocation_base_key: SecretKey::from_slice(&self.secp_ctx, &[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]).unwrap(), |
240 |
| - payment_base_key: SecretKey::from_slice(&self.secp_ctx, &[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]).unwrap(), |
| 238 | + funding_key: SecretKey::from_slice(&self.secp_ctx, &[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]).unwrap(), |
| 239 | + revocation_base_key: SecretKey::from_slice(&self.secp_ctx, &[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]).unwrap(), |
| 240 | + payment_base_key: SecretKey::from_slice(&self.secp_ctx, &[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]).unwrap(), |
241 | 241 | delayed_payment_base_key: SecretKey::from_slice(&self.secp_ctx, &[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]).unwrap(),
|
242 |
| - htlc_base_key: SecretKey::from_slice(&self.secp_ctx, &[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]).unwrap(), |
243 |
| - channel_close_key: SecretKey::from_slice(&self.secp_ctx, &[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]).unwrap(), |
| 242 | + htlc_base_key: SecretKey::from_slice(&self.secp_ctx, &[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]).unwrap(), |
| 243 | + channel_close_key: SecretKey::from_slice(&self.secp_ctx, &[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]).unwrap(), |
244 | 244 | channel_monitor_claim_key: SecretKey::from_slice(&self.secp_ctx, &[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]).unwrap(),
|
245 | 245 | commitment_seed: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
246 | 246 | }
|
@@ -661,12 +661,12 @@ impl ChannelManager {
|
661 | 661 |
|
662 | 662 | /// Call this upon creation of a funding transaction for the given channel.
|
663 | 663 | /// Panics if a funding transaction has already been provided for this channel.
|
664 |
| - pub fn funding_transaction_generated(&self, temporary_channel_id: &Uint256, funding_txo: (Sha256dHash, u16)) { |
| 664 | + pub fn funding_transaction_generated(&self, temporary_channel_id: &Uint256, funding_txo: TxOutRef) { |
665 | 665 | let (chan, msg, chan_monitor) = {
|
666 | 666 | let mut channel_state = self.channel_state.lock().unwrap();
|
667 | 667 | match channel_state.by_id.remove(&temporary_channel_id) {
|
668 | 668 | Some(mut chan) => {
|
669 |
| - match chan.get_outbound_funding_created(funding_txo.0, funding_txo.1) { |
| 669 | + match chan.get_outbound_funding_created(funding_txo.txid, funding_txo.index as u16) { |
670 | 670 | Ok(funding_msg) => {
|
671 | 671 | (chan, funding_msg.0, funding_msg.1)
|
672 | 672 | },
|
@@ -1029,7 +1029,7 @@ impl ChainListener for ChannelManager {
|
1029 | 1029 | if let Some(funding_txo) = channel.get_funding_txo() {
|
1030 | 1030 | for tx in txn_matched {
|
1031 | 1031 | for inp in tx.input.iter() {
|
1032 |
| - if inp.prev_hash == funding_txo.0 && inp.prev_index == funding_txo.1 as u32 { |
| 1032 | + if inp.prev_hash == funding_txo.txid && inp.prev_index == funding_txo.index as u32 { |
1033 | 1033 | if let Some(short_id) = channel.get_short_channel_id() {
|
1034 | 1034 | short_to_ids_to_remove.push(short_id);
|
1035 | 1035 | }
|
@@ -1094,12 +1094,12 @@ impl ChannelMessageHandler for ChannelManager {
|
1094 | 1094 |
|
1095 | 1095 | let chan_keys = if cfg!(feature = "fuzztarget") {
|
1096 | 1096 | ChannelKeys {
|
1097 |
| - funding_key: SecretKey::from_slice(&self.secp_ctx, &[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]).unwrap(), |
1098 |
| - revocation_base_key: SecretKey::from_slice(&self.secp_ctx, &[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]).unwrap(), |
1099 |
| - payment_base_key: SecretKey::from_slice(&self.secp_ctx, &[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]).unwrap(), |
| 1097 | + funding_key: SecretKey::from_slice(&self.secp_ctx, &[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]).unwrap(), |
| 1098 | + revocation_base_key: SecretKey::from_slice(&self.secp_ctx, &[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]).unwrap(), |
| 1099 | + payment_base_key: SecretKey::from_slice(&self.secp_ctx, &[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]).unwrap(), |
1100 | 1100 | delayed_payment_base_key: SecretKey::from_slice(&self.secp_ctx, &[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]).unwrap(),
|
1101 |
| - htlc_base_key: SecretKey::from_slice(&self.secp_ctx, &[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]).unwrap(), |
1102 |
| - channel_close_key: SecretKey::from_slice(&self.secp_ctx, &[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]).unwrap(), |
| 1101 | + htlc_base_key: SecretKey::from_slice(&self.secp_ctx, &[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]).unwrap(), |
| 1102 | + channel_close_key: SecretKey::from_slice(&self.secp_ctx, &[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]).unwrap(), |
1103 | 1103 | channel_monitor_claim_key: SecretKey::from_slice(&self.secp_ctx, &[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]).unwrap(),
|
1104 | 1104 | commitment_seed: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
1105 | 1105 | }
|
@@ -1578,7 +1578,7 @@ impl ChannelMessageHandler for ChannelManager {
|
1578 | 1578 |
|
1579 | 1579 | let mut hmac = Hmac::new(Sha256::new(), &um);
|
1580 | 1580 | hmac.input(&err_packet.encode()[32..]);
|
1581 |
| - let mut calc_tag = [0u8; 32]; |
| 1581 | + let mut calc_tag = [0u8; 32]; |
1582 | 1582 | hmac.raw_result(&mut calc_tag);
|
1583 | 1583 | if crypto::util::fixed_time_eq(&calc_tag, &err_packet.hmac) {
|
1584 | 1584 | const UNKNOWN_CHAN: u16 = 0x4000|10;
|
@@ -1812,7 +1812,7 @@ mod tests {
|
1812 | 1812 | use bitcoin::util::hash::Sha256dHash;
|
1813 | 1813 | use bitcoin::util::uint::Uint256;
|
1814 | 1814 | use bitcoin::blockdata::block::BlockHeader;
|
1815 |
| - use bitcoin::blockdata::transaction::{Transaction, TxOut}; |
| 1815 | + use bitcoin::blockdata::transaction::{Transaction, TxOut, TxOutRef}; |
1816 | 1816 | use bitcoin::network::constants::Network;
|
1817 | 1817 | use bitcoin::network::serialize::serialize;
|
1818 | 1818 | use bitcoin::network::serialize::BitcoinHash;
|
@@ -2020,7 +2020,10 @@ mod tests {
|
2020 | 2020 | tx = Transaction { version: chan_id as u32, lock_time: 0, input: Vec::new(), output: vec![TxOut {
|
2021 | 2021 | value: *channel_value_satoshis, script_pubkey: output_script.clone(),
|
2022 | 2022 | }]};
|
2023 |
| - funding_output = (Sha256dHash::from_data(&serialize(&tx).unwrap()[..]), 0); |
| 2023 | + funding_output = TxOutRef { |
| 2024 | + txid: Sha256dHash::from_data(&serialize(&tx).unwrap()[..]), |
| 2025 | + index: 0 |
| 2026 | + }; |
2024 | 2027 |
|
2025 | 2028 | node_a.node.funding_transaction_generated(&temporary_channel_id, funding_output.clone());
|
2026 | 2029 | let mut added_monitors = node_a.chan_monitor.added_monitors.lock().unwrap();
|
|
0 commit comments