Specify amount units in HolderHTLCOutput
[rust-lightning] / lightning / src / chain / package.rs
index cf92df2952148dd11f25838422010ead1281ae9d..35d90fb31812434afacffb33e4cb8ca798da319e 100644 (file)
@@ -27,7 +27,6 @@ use crate::ln::msgs::DecodeError;
 use crate::chain::chaininterface::{FeeEstimator, ConfirmationTarget, MIN_RELAY_FEE_SAT_PER_1000_WEIGHT};
 use crate::chain::keysinterface::Sign;
 use crate::chain::onchaintx::OnchainTxHandler;
-use crate::util::byte_utils;
 use crate::util::logger::Logger;
 use crate::util::ser::{Readable, Writer, Writeable};
 
@@ -253,31 +252,31 @@ impl_writeable_tlv_based!(CounterpartyReceivedHTLCOutput, {
 #[derive(Clone, PartialEq, Eq)]
 pub(crate) struct HolderHTLCOutput {
        preimage: Option<PaymentPreimage>,
-       amount: u64,
+       amount_msat: u64,
        /// Defaults to 0 for HTLC-Success transactions, which have no expiry
        cltv_expiry: u32,
 }
 
 impl HolderHTLCOutput {
-       pub(crate) fn build_offered(amount: u64, cltv_expiry: u32) -> Self {
+       pub(crate) fn build_offered(amount_msat: u64, cltv_expiry: u32) -> Self {
                HolderHTLCOutput {
                        preimage: None,
-                       amount,
+                       amount_msat,
                        cltv_expiry,
                }
        }
 
-       pub(crate) fn build_accepted(preimage: PaymentPreimage, amount: u64) -> Self {
+       pub(crate) fn build_accepted(preimage: PaymentPreimage, amount_msat: u64) -> Self {
                HolderHTLCOutput {
                        preimage: Some(preimage),
-                       amount,
+                       amount_msat,
                        cltv_expiry: 0,
                }
        }
 }
 
 impl_writeable_tlv_based!(HolderHTLCOutput, {
-       (0, amount, required),
+       (0, amount_msat, required),
        (2, cltv_expiry, required),
        (4, preimage, option)
 });
@@ -770,7 +769,7 @@ impl PackageTemplate {
 
 impl Writeable for PackageTemplate {
        fn write<W: Writer>(&self, writer: &mut W) -> Result<(), io::Error> {
-               writer.write_all(&byte_utils::be64_to_array(self.inputs.len() as u64))?;
+               writer.write_all(&(self.inputs.len() as u64).to_be_bytes())?;
                for (ref outpoint, ref rev_outp) in self.inputs.iter() {
                        outpoint.write(writer)?;
                        rev_outp.write(writer)?;