Skip to content

Commit f4be2b2

Browse files
committed
f - move SigningPubkey to separate module
1 parent 2f9ce37 commit f4be2b2

File tree

3 files changed

+32
-16
lines changed

3 files changed

+32
-16
lines changed

lightning/src/offers/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ pub mod offer;
1919
pub mod parse;
2020
mod payer;
2121
pub mod refund;
22+
pub mod signer;

lightning/src/offers/offer.rs

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ use crate::ln::msgs::MAX_VALUE_MSAT;
8383
use crate::offers::invoice_request::InvoiceRequestBuilder;
8484
use crate::offers::merkle::TlvStream;
8585
use crate::offers::parse::{Bech32Encode, ParseError, ParsedMessage, SemanticError};
86+
use crate::offers::signer::SigningPubkey;
8687
use crate::onion_message::BlindedPath;
8788
use crate::util::ser::{HighZeroBytesDroppedBigSize, WithoutLength, Writeable, Writer};
8889
use crate::util::string::PrintableString;
@@ -92,21 +93,6 @@ use crate::prelude::*;
9293
#[cfg(feature = "std")]
9394
use std::time::SystemTime;
9495

95-
/// A pubkey for signing invoices, either given explicitly or derived.
96-
pub enum SigningPubkey<'a> {
97-
/// A pubkey that is typically known like a node id.
98-
Explicit(PublicKey),
99-
100-
/// Data needed to derive a pubkey.
101-
Derived(&'a ExpandedKey, Nonce),
102-
}
103-
104-
impl<'a> From<PublicKey> for SigningPubkey<'a> {
105-
fn from(pubkey: PublicKey) -> Self {
106-
SigningPubkey::Explicit(pubkey)
107-
}
108-
}
109-
11096
/// Builds an [`Offer`] for the "offer to be paid" flow.
11197
///
11298
/// See [module-level documentation] for usage.
@@ -760,7 +746,7 @@ impl core::fmt::Display for Offer {
760746

761747
#[cfg(test)]
762748
mod tests {
763-
use super::{Amount, Offer, OfferBuilder, OfferTlvStreamRef, Quantity, SigningPubkey};
749+
use super::{Amount, Offer, OfferBuilder, OfferTlvStreamRef, Quantity};
764750

765751
use bitcoin::blockdata::constants::ChainHash;
766752
use bitcoin::network::constants::Network;
@@ -774,6 +760,7 @@ mod tests {
774760
use crate::ln::inbound_payment::{ExpandedKey, Nonce};
775761
use crate::ln::msgs::{DecodeError, MAX_VALUE_MSAT};
776762
use crate::offers::parse::{ParseError, SemanticError};
763+
use crate::offers::signer::SigningPubkey;
777764
use crate::onion_message::{BlindedHop, BlindedPath};
778765
use crate::util::ser::{BigSize, Writeable};
779766
use crate::util::string::PrintableString;

lightning/src/offers/signer.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// This file is Copyright its original authors, visible in version control
2+
// history.
3+
//
4+
// This file is licensed under the Apache License, Version 2.0 <LICENSE-APACHE
5+
// or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
6+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option.
7+
// You may not use this file except in accordance with one or both of these
8+
// licenses.
9+
10+
//! Data structures for signing offer messages.
11+
12+
use bitcoin::secp256k1::PublicKey;
13+
use crate::ln::inbound_payment::{ExpandedKey, Nonce};
14+
15+
/// A pubkey for signing messages, either given explicitly or derived.
16+
pub enum SigningPubkey<'a> {
17+
/// A pubkey that is typically known like a node id.
18+
Explicit(PublicKey),
19+
20+
/// Data needed to derive a pubkey.
21+
Derived(&'a ExpandedKey, Nonce),
22+
}
23+
24+
impl<'a> From<PublicKey> for SigningPubkey<'a> {
25+
fn from(pubkey: PublicKey) -> Self {
26+
SigningPubkey::Explicit(pubkey)
27+
}
28+
}

0 commit comments

Comments
 (0)