Merge pull request #786 from TheBlueMatt/2021-02-chansigner-util
authorMatt Corallo <649246+TheBlueMatt@users.noreply.github.com>
Tue, 16 Feb 2021 17:33:37 +0000 (09:33 -0800)
committerGitHub <noreply@github.com>
Tue, 16 Feb 2021 17:33:37 +0000 (09:33 -0800)
Expand documentation and fields in SpendableOutputDescriptors

1  2 
lightning/src/ln/functional_tests.rs

index 9ac79aa159faa5212f9622069f83b1481909cc67,eef8199e8e43eaa3aa63c68e40b7a12966485780..53e7649d19b693effba8790f66da986eb482a35e
@@@ -1583,7 -1583,7 +1583,7 @@@ fn test_fee_spike_violation_fails_htlc(
                        let route = get_route(&nodes[0].node.get_our_node_id(), net_graph_msg_handler, &nodes.last().unwrap().node.get_our_node_id(), None, &Vec::new(), $recv_value, TEST_FINAL_CLTV, &logger).unwrap();
                        (route, payment_hash, payment_preimage)
                }}
 -      };
 +      }
  
        let (route, payment_hash, _) = get_route_and_payment_hash!(3460001);
        // Need to manually create the update_add_htlc message to go around the channel reserve check in send_htlc()
@@@ -1722,7 -1722,7 +1722,7 @@@ fn test_chan_reserve_violation_outbound
                        let route = get_route(&nodes[1].node.get_our_node_id(), &net_graph_msg_handler.network_graph.read().unwrap(), &nodes.first().unwrap().node.get_our_node_id(), None, &Vec::new(), $recv_value, TEST_FINAL_CLTV, &logger).unwrap();
                        (route, payment_hash, payment_preimage)
                }}
 -      };
 +      }
  
        let (route, our_payment_hash, _) = get_route_and_payment_hash!(1000);
        unwrap_send_err!(nodes[1].node.send_payment(&route, our_payment_hash, &None), true, APIError::ChannelUnavailable { ref err },
@@@ -1754,7 -1754,7 +1754,7 @@@ fn test_chan_reserve_violation_inbound_
                        let route = get_route(&nodes[1].node.get_our_node_id(), &net_graph_msg_handler.network_graph.read().unwrap(), &nodes.first().unwrap().node.get_our_node_id(), None, &Vec::new(), $recv_value, TEST_FINAL_CLTV, &logger).unwrap();
                        (route, payment_hash, payment_preimage)
                }}
 -      };
 +      }
  
        let (route, payment_hash, _) = get_route_and_payment_hash!(1000);
        // Need to manually create the update_add_htlc message to go around the channel reserve check in send_htlc()
@@@ -1799,7 -1799,7 +1799,7 @@@ fn test_chan_reserve_violation_inbound_
                        let route = get_route(&nodes[0].node.get_our_node_id(), &net_graph_msg_handler.network_graph.read().unwrap(), &nodes.last().unwrap().node.get_our_node_id(), None, &Vec::new(), $recv_value, TEST_FINAL_CLTV, &logger).unwrap();
                        (route, payment_hash, payment_preimage)
                }}
 -      };
 +      }
  
        let feemsat = 239;
        let total_routing_fee_msat = (nodes.len() - 2) as u64 * feemsat;
@@@ -1900,7 -1900,7 +1900,7 @@@ fn test_channel_reserve_holding_cell_ht
                        let route = get_route(&nodes[0].node.get_our_node_id(), &net_graph_msg_handler.network_graph.read().unwrap(), &nodes.last().unwrap().node.get_our_node_id(), None, &Vec::new(), $recv_value, TEST_FINAL_CLTV, &logger).unwrap();
                        (route, payment_hash, payment_preimage)
                }}
 -      };
 +      }
  
        macro_rules! expect_forward {
                ($node: expr) => {{
@@@ -4662,7 -4662,8 +4662,8 @@@ macro_rules! check_spendable_outputs 
                                        Event::SpendableOutputs { ref outputs } => {
                                                for outp in outputs {
                                                        match *outp {
-                                                               SpendableOutputDescriptor::StaticOutputCounterpartyPayment { ref outpoint, ref output, ref key_derivation_params } => {
+                                                               SpendableOutputDescriptor::StaticOutputCounterpartyPayment { ref outpoint, ref output, ref channel_keys_id, channel_value_satoshis } => {
+                                                                       assert_eq!(channel_value_satoshis, $chan_value);
                                                                        let input = TxIn {
                                                                                previous_output: outpoint.into_bitcoin_outpoint(),
                                                                                script_sig: Script::new(),
                                                                        };
                                                                        spend_tx.output[0].value -= (spend_tx.get_weight() + 2 + 1 + 73 + 35 + 3) as u64 / 4; // (Max weight + 3 (to round up)) / 4
                                                                        let secp_ctx = Secp256k1::new();
-                                                                       let keys = $keysinterface.derive_channel_keys($chan_value, key_derivation_params.0, key_derivation_params.1);
+                                                                       let keys = $keysinterface.derive_channel_keys($chan_value, channel_keys_id);
                                                                        let remotepubkey = keys.pubkeys().payment_point;
                                                                        let witness_script = Address::p2pkh(&::bitcoin::PublicKey{compressed: true, key: remotepubkey}, Network::Testnet).script_pubkey();
                                                                        let sighash = Message::from_slice(&bip143::SigHashCache::new(&spend_tx).signature_hash(0, &witness_script, output.value, SigHashType::All)[..]).unwrap();
                                                                        spend_tx.input[0].witness.push(remotepubkey.serialize().to_vec());
                                                                        txn.push(spend_tx);
                                                                },
-                                                               SpendableOutputDescriptor::DynamicOutputP2WSH { ref outpoint, ref per_commitment_point, ref to_self_delay, ref output, ref key_derivation_params, ref revocation_pubkey } => {
+                                                               SpendableOutputDescriptor::DynamicOutputP2WSH { ref outpoint, ref per_commitment_point, ref to_self_delay, ref output, ref revocation_pubkey, ref channel_keys_id, channel_value_satoshis  } => {
+                                                                       assert_eq!(channel_value_satoshis, $chan_value);
                                                                        let input = TxIn {
                                                                                previous_output: outpoint.into_bitcoin_outpoint(),
                                                                                script_sig: Script::new(),
                                                                                output: vec![outp],
                                                                        };
                                                                        let secp_ctx = Secp256k1::new();
-                                                                       let keys = $keysinterface.derive_channel_keys($chan_value, key_derivation_params.0, key_derivation_params.1);
+                                                                       let keys = $keysinterface.derive_channel_keys($chan_value, channel_keys_id);
                                                                        if let Ok(delayed_payment_key) = chan_utils::derive_private_key(&secp_ctx, &per_commitment_point, &keys.inner.delayed_payment_base_key) {
  
                                                                                let delayed_payment_pubkey = PublicKey::from_secret_key(&secp_ctx, &delayed_payment_key);
@@@ -7484,7 -7486,7 +7486,7 @@@ fn test_data_loss_protect() 
        let header = BlockHeader { version: 0x20000000, prev_blockhash: Default::default(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42};
        connect_block(&nodes[0], &Block { header, txdata: vec![node_txn[0].clone()]}, 0);
        connect_blocks(&nodes[0], ANTI_REORG_DELAY - 1, 0, true, header.block_hash());
-       let spend_txn = check_spendable_outputs!(nodes[0], 1, node_cfgs[0].keys_manager, 100000);
+       let spend_txn = check_spendable_outputs!(nodes[0], 1, node_cfgs[0].keys_manager, 1000000);
        assert_eq!(spend_txn.len(), 1);
        check_spends!(spend_txn[0], node_txn[0]);
  }