use bitcoin::secp256k1::Signature;
use bitcoin::secp256k1::key::{PublicKey, SecretKey};
+use bitcoin::secp256k1::constants::{PUBLIC_KEY_SIZE, COMPACT_SIGNATURE_SIZE};
use bitcoin::blockdata::script::Script;
use bitcoin::blockdata::transaction::{OutPoint, Transaction, TxOut};
use bitcoin::consensus;
use bitcoin::hash_types::{Txid, BlockHash};
use std::marker::Sized;
use ln::msgs::DecodeError;
-use ln::channelmanager::{PaymentPreimage, PaymentHash, PaymentSecret};
+use ln::{PaymentPreimage, PaymentHash, PaymentSecret};
use util::byte_utils;
use util::byte_utils::{be64_to_array, be48_to_array, be32_to_array, be16_to_array, slice_to_be16, slice_to_be32, slice_to_be48, slice_to_be64};
impl_array!(10); // for OnionV2
impl_array!(16); // for IPv6
impl_array!(32); // for channel id & hmac
-impl_array!(33); // for PublicKey
-impl_array!(64); // for Signature
+impl_array!(PUBLIC_KEY_SIZE); // for PublicKey
+impl_array!(COMPACT_SIGNATURE_SIZE); // for Signature
impl_array!(1300); // for OnionPacket.hop_data
// HashMap
fn read<R: Read>(r: &mut R) -> Result<Self, DecodeError> {
let len: u16 = Readable::read(r)?;
let byte_size = (len as usize)
- .checked_mul(33)
+ .checked_mul(COMPACT_SIGNATURE_SIZE)
.ok_or(DecodeError::BadLengthDescriptor)?;
if byte_size > MAX_BUF_SIZE {
return Err(DecodeError::BadLengthDescriptor);
impl Readable for PublicKey {
fn read<R: Read>(r: &mut R) -> Result<Self, DecodeError> {
- let buf: [u8; 33] = Readable::read(r)?;
+ let buf: [u8; PUBLIC_KEY_SIZE] = Readable::read(r)?;
match PublicKey::from_slice(&buf) {
Ok(key) => Ok(key),
Err(_) => return Err(DecodeError::InvalidValue),
impl Readable for Signature {
fn read<R: Read>(r: &mut R) -> Result<Self, DecodeError> {
- let buf: [u8; 64] = Readable::read(r)?;
+ let buf: [u8; COMPACT_SIGNATURE_SIZE] = Readable::read(r)?;
match Signature::from_compact(&buf) {
Ok(sig) => Ok(sig),
Err(_) => return Err(DecodeError::InvalidValue),