Skip to content

Minor Tweaks to lightning-invoice for C bindings #908

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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