Skip to content

Commit

Permalink
Merge pull request #908 from TheBlueMatt/2021-04-invoice-real-bindings
Browse files Browse the repository at this point in the history
Minor Tweaks to lightning-invoice for C bindings
  • Loading branch information
TheBlueMatt authored May 1, 2021
2 parents e26c3df + 83ab933 commit d4d3225
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
4 changes: 3 additions & 1 deletion lightning-invoice/src/de.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ use secp256k1;
use secp256k1::recovery::{RecoveryId, RecoverableSignature};
use secp256k1::key::PublicKey;

use super::*;
use super::{Invoice, Sha256, TaggedField, ExpiryTime, MinFinalCltvExpiry, Fallback, PayeePubKey, InvoiceSignature, PositiveTimestamp,
SemanticError, RouteHint, Description, RawTaggedField, Currency, RawHrp, SiPrefix, RawInvoice, constants, SignedRawInvoice,
RawDataPart, CreationError, InvoiceFeatures};

use self::hrp_sm::parse_hrp;

Expand Down
9 changes: 6 additions & 3 deletions lightning-invoice/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,8 @@ pub enum Currency {
}

/// Tagged field which may have an unknown tag
///
/// (C-not exported) as we don't currently support TaggedField
#[derive(Eq, PartialEq, Debug, Clone)]
pub enum RawTaggedField {
/// Parsed tagged field with known tag
Expand All @@ -343,6 +345,9 @@ pub enum RawTaggedField {
/// Tagged field with known tag
///
/// For descriptions of the enum values please refer to the enclosed type's docs.
///
/// (C-not exported) As we don't yet support enum variants with the same name the struct contained
/// in the variant.
#[allow(missing_docs)]
#[derive(Eq, PartialEq, Debug, Clone)]
pub enum TaggedField {
Expand Down Expand Up @@ -1322,10 +1327,8 @@ impl std::error::Error for SemanticError { }

/// When signing using a fallible method either an user-supplied `SignError` or a `CreationError`
/// may occur.
///
/// (C-not exported) As we don't support unbounded generics
#[derive(Eq, PartialEq, Debug, Clone)]
pub enum SignOrCreationError<S> {
pub enum SignOrCreationError<S = ()> {
/// An error occurred during signing
SignError(S),

Expand Down
4 changes: 3 additions & 1 deletion lightning-invoice/src/ser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ use std::fmt;
use std::fmt::{Display, Formatter};
use bech32::{ToBase32, u5, WriteBase32, Base32Len};

use ::*;
use super::{Invoice, Sha256, TaggedField, ExpiryTime, MinFinalCltvExpiry, Fallback, PayeePubKey, InvoiceSignature, PositiveTimestamp,
RouteHint, Description, RawTaggedField, Currency, RawHrp, SiPrefix, constants, SignedRawInvoice, RawDataPart};

/// Converts a stream of bytes written to it to base32. On finalization the according padding will
/// be applied. That means the results of writing two data blocks with one or two `BytesToBase32`
Expand Down Expand Up @@ -122,6 +123,7 @@ impl Display for SignedRawInvoice {
}
}

/// (C-not exported)
impl Display for RawHrp {
fn fmt(&self, f: &mut Formatter) -> Result<(), fmt::Error> {
let amount = match self.raw_amount {
Expand Down

0 comments on commit d4d3225

Please sign in to comment.