pub(crate) data: OnionRealm0HopData,
pub(crate) hmac: [u8; 32],
}
- unsafe impl ::util::internal_traits::NoDealloc for OnionHopData{}
pub struct DecodedOnionErrorPacket {
pub(crate) hmac: [u8; 32],
use ln::channelmanager::{PaymentHash, HTLCSource};
use ln::msgs;
use ln::router::{Route,RouteHop};
-use util::{byte_utils, internal_traits};
+use util::byte_utils;
use util::chacha20::ChaCha20;
use util::errors::{self, APIError};
use util::ser::{Readable, Writeable};
use secp256k1::ecdh::SharedSecret;
use secp256k1;
-use std::ptr;
use std::io::Cursor;
use std::sync::Arc;
let mut cur_cltv = starting_htlc_offset;
let mut last_short_channel_id = 0;
let mut res: Vec<msgs::OnionHopData> = Vec::with_capacity(route.hops.len());
- internal_traits::test_no_dealloc::<msgs::OnionHopData>(None);
- unsafe { res.set_len(route.hops.len()); }
for (idx, hop) in route.hops.iter().enumerate().rev() {
// First hop gets special values so that it can check, on receipt, that everything is
// the intended recipient).
let value_msat = if cur_value_msat == 0 { hop.fee_msat } else { cur_value_msat };
let cltv = if cur_cltv == starting_htlc_offset { hop.cltv_expiry_delta + starting_htlc_offset } else { cur_cltv };
- res[idx] = msgs::OnionHopData {
+ res.insert(0, msgs::OnionHopData {
realm: 0,
data: msgs::OnionRealm0HopData {
short_channel_id: last_short_channel_id,
outgoing_cltv_value: cltv,
},
hmac: [0; 32],
- };
+ });
cur_value_msat += hop.fee_msat;
if cur_value_msat >= 21000000 * 100000000 * 1000 {
return Err(APIError::RouteError{err: "Channel fees overflowed?!"});
#[inline]
fn shift_arr_right(arr: &mut [u8; 20*65]) {
- unsafe {
- ptr::copy(arr[0..].as_ptr(), arr[65..].as_mut_ptr(), 19*65);
+ for i in (65..20*65).rev() {
+ arr[i] = arr[i-65];
}
for i in 0..65 {
arr[i] = 0;