hrp.as_bytes(),
&data[..data.len()-104]
),
- signature: Signature::from_base32(&data[data.len()-104..])?,
+ signature: InvoiceSignature::from_base32(&data[data.len()-104..])?,
})
}
}
}
}
-impl FromBase32 for Signature {
+impl FromBase32 for InvoiceSignature {
type Err = ParseError;
fn from_base32(signature: &[u5]) -> Result<Self, Self::Err> {
if signature.len() != 104 {
- return Err(ParseError::InvalidSliceLength("Signature::from_base32()".into()));
+ return Err(ParseError::InvalidSliceLength("InvoiceSignature::from_base32()".into()));
}
let recoverable_signature_bytes = Vec::<u8>::from_base32(signature)?;
let signature = &recoverable_signature_bytes[0..64];
let recovery_id = RecoveryId::from_i32(recoverable_signature_bytes[64] as i32)?;
- Ok(Signature(RecoverableSignature::from_compact(
+ Ok(InvoiceSignature(RecoverableSignature::from_compact(
signature,
recovery_id
)?))
use lightning::ln::features::InvoiceFeatures;
use secp256k1::recovery::{RecoveryId, RecoverableSignature};
use TaggedField::*;
- use {SiPrefix, SignedRawInvoice, Signature, RawInvoice, RawHrp, RawDataPart,
+ use {SiPrefix, SignedRawInvoice, InvoiceSignature, RawInvoice, RawHrp, RawDataPart,
Currency, Sha256, PositiveTimestamp};
// Feature bits 9, 15, and 99 are set.
hash: [0xb1, 0x96, 0x46, 0xc3, 0xbc, 0x56, 0x76, 0x1d, 0x20, 0x65, 0x6e, 0x0e, 0x32,
0xec, 0xd2, 0x69, 0x27, 0xb7, 0x62, 0x6e, 0x2a, 0x8b, 0xe6, 0x97, 0x71, 0x9f,
0xf8, 0x7e, 0x44, 0x54, 0x55, 0xb9],
- signature: Signature(RecoverableSignature::from_compact(
+ signature: InvoiceSignature(RecoverableSignature::from_compact(
&[0xd7, 0x90, 0x4c, 0xc4, 0xb7, 0x4a, 0x22, 0x26, 0x9c, 0x68, 0xc1, 0xdf, 0x68,
0xa9, 0x6c, 0x21, 0x4d, 0x65, 0x1b, 0x93, 0x76, 0xe9, 0xf1, 0x64, 0xd3, 0x60,
0x4d, 0xa4, 0xb7, 0xde, 0xcc, 0xce, 0x0e, 0x82, 0xaa, 0xab, 0x4c, 0x85, 0xd3,
fn test_raw_signed_invoice_deserialization() {
use TaggedField::*;
use secp256k1::recovery::{RecoveryId, RecoverableSignature};
- use {SignedRawInvoice, Signature, RawInvoice, RawHrp, RawDataPart, Currency, Sha256,
+ use {SignedRawInvoice, InvoiceSignature, RawInvoice, RawHrp, RawDataPart, Currency, Sha256,
PositiveTimestamp};
assert_eq!(
0x7b, 0x1d, 0x85, 0x8d, 0xb1, 0xd1, 0xf7, 0xab, 0x71, 0x37, 0xdc, 0xb7,
0x83, 0x5d, 0xb2, 0xec, 0xd5, 0x18, 0xe1, 0xc9
],
- signature: Signature(RecoverableSignature::from_compact(
+ signature: InvoiceSignature(RecoverableSignature::from_compact(
& [
0x38u8, 0xec, 0x68, 0x91, 0x34, 0x5e, 0x20, 0x41, 0x45, 0xbe, 0x8a,
0x3a, 0x99, 0xde, 0x38, 0xe9, 0x8a, 0x39, 0xd6, 0xa5, 0x69, 0x43,
hash: [u8; 32],
/// signature of the payment request
- signature: Signature,
+ signature: InvoiceSignature,
}
/// Represents an syntactically correct Invoice for a payment on the lightning network,
/// Recoverable signature
#[derive(Eq, PartialEq, Debug, Clone)]
-pub struct Signature(pub RecoverableSignature);
+pub struct InvoiceSignature(pub RecoverableSignature);
/// Private routing information
///
/// 1. raw invoice
/// 2. hash of the raw invoice
/// 3. signature
- pub fn into_parts(self) -> (RawInvoice, [u8; 32], Signature) {
+ pub fn into_parts(self) -> (RawInvoice, [u8; 32], InvoiceSignature) {
(self.raw_invoice, self.hash, self.signature)
}
&self.hash
}
- /// Signature for the invoice.
- pub fn signature(&self) -> &Signature {
+ /// InvoiceSignature for the invoice.
+ pub fn signature(&self) -> &InvoiceSignature {
&self.signature
}
Ok(SignedRawInvoice {
raw_invoice: self,
hash: raw_hash,
- signature: Signature(signature),
+ signature: InvoiceSignature(signature),
})
}
}
}
-impl Deref for Signature {
+impl Deref for InvoiceSignature {
type Target = RecoverableSignature;
fn deref(&self) -> &RecoverableSignature {
use secp256k1::Secp256k1;
use secp256k1::recovery::{RecoveryId, RecoverableSignature};
use secp256k1::key::{SecretKey, PublicKey};
- use {SignedRawInvoice, Signature, RawInvoice, RawHrp, RawDataPart, Currency, Sha256,
+ use {SignedRawInvoice, InvoiceSignature, RawInvoice, RawHrp, RawDataPart, Currency, Sha256,
PositiveTimestamp};
let invoice = SignedRawInvoice {
0x7b, 0x1d, 0x85, 0x8d, 0xb1, 0xd1, 0xf7, 0xab, 0x71, 0x37, 0xdc, 0xb7,
0x83, 0x5d, 0xb2, 0xec, 0xd5, 0x18, 0xe1, 0xc9
],
- signature: Signature(RecoverableSignature::from_compact(
+ signature: InvoiceSignature(RecoverableSignature::from_compact(
& [
0x38u8, 0xec, 0x68, 0x91, 0x34, 0x5e, 0x20, 0x41, 0x45, 0xbe, 0x8a,
0x3a, 0x99, 0xde, 0x38, 0xe9, 0x8a, 0x39, 0xd6, 0xa5, 0x69, 0x43,