X-Git-Url: http://git.bitcoin.ninja/index.cgi?p=ldk-c-bindings;a=blobdiff_plain;f=lightning-c-bindings%2Fsrc%2Flightning_invoice%2Fmod.rs;h=7ab1c2ede2be551286d1eb80e2afce77fbf6dde1;hp=eaa9aabbbc9258bb3d3dbe204f679b6fa695ea52;hb=2f0c348c6fe505a736c3d015df6d6cd30032c912;hpb=e419524cf19c36857bf1f3c79d4b9dd47c7544c8 diff --git a/lightning-c-bindings/src/lightning_invoice/mod.rs b/lightning-c-bindings/src/lightning_invoice/mod.rs index eaa9aab..7ab1c2e 100644 --- a/lightning-c-bindings/src/lightning_invoice/mod.rs +++ b/lightning-c-bindings/src/lightning_invoice/mod.rs @@ -110,6 +110,22 @@ use bitcoin::hashes::Hash; use crate::c_types::*; } +/// Default expiry time as defined by [BOLT 11]. +/// +/// [BOLT 11]: https://github.com/lightningnetwork/lightning-rfc/blob/master/11-payment-encoding.md + +#[no_mangle] +pub static DEFAULT_EXPIRY_TIME: u64 = lightning_invoice::DEFAULT_EXPIRY_TIME; +/// Default minimum final CLTV expiry as defined by [BOLT 11]. +/// +/// Note that this is *not* the same value as rust-lightning's minimum CLTV expiry, which is +/// provided in [`MIN_FINAL_CLTV_EXPIRY`]. +/// +/// [BOLT 11]: https://github.com/lightningnetwork/lightning-rfc/blob/master/11-payment-encoding.md +/// [`MIN_FINAL_CLTV_EXPIRY`]: lightning::ln::channelmanager::MIN_FINAL_CLTV_EXPIRY + +#[no_mangle] +pub static DEFAULT_MIN_FINAL_CLTV_EXPIRY: u64 = lightning_invoice::DEFAULT_MIN_FINAL_CLTV_EXPIRY; /// **Call this function on startup to ensure that all assumptions about the platform are valid.** /// /// Unfortunately we have to make assumptions about the upper bounds of the `SystemTime` type on @@ -591,6 +607,22 @@ impl SiPrefix { pub extern "C" fn SiPrefix_clone(orig: &SiPrefix) -> SiPrefix { orig.clone() } +#[no_mangle] +/// Utility method to constructs a new Milli-variant SiPrefix +pub extern "C" fn SiPrefix_milli() -> SiPrefix { + SiPrefix::Milli} +#[no_mangle] +/// Utility method to constructs a new Micro-variant SiPrefix +pub extern "C" fn SiPrefix_micro() -> SiPrefix { + SiPrefix::Micro} +#[no_mangle] +/// Utility method to constructs a new Nano-variant SiPrefix +pub extern "C" fn SiPrefix_nano() -> SiPrefix { + SiPrefix::Nano} +#[no_mangle] +/// Utility method to constructs a new Pico-variant SiPrefix +pub extern "C" fn SiPrefix_pico() -> SiPrefix { + SiPrefix::Pico} /// Checks if two SiPrefixs contain equal inner contents. /// This ignores pointers and is_owned flags and looks at the values in fields. #[no_mangle] @@ -670,6 +702,26 @@ impl Currency { pub extern "C" fn Currency_clone(orig: &Currency) -> Currency { orig.clone() } +#[no_mangle] +/// Utility method to constructs a new Bitcoin-variant Currency +pub extern "C" fn Currency_bitcoin() -> Currency { + Currency::Bitcoin} +#[no_mangle] +/// Utility method to constructs a new BitcoinTestnet-variant Currency +pub extern "C" fn Currency_bitcoin_testnet() -> Currency { + Currency::BitcoinTestnet} +#[no_mangle] +/// Utility method to constructs a new Regtest-variant Currency +pub extern "C" fn Currency_regtest() -> Currency { + Currency::Regtest} +#[no_mangle] +/// Utility method to constructs a new Simnet-variant Currency +pub extern "C" fn Currency_simnet() -> Currency { + Currency::Simnet} +#[no_mangle] +/// Utility method to constructs a new Signet-variant Currency +pub extern "C" fn Currency_signet() -> Currency { + Currency::Signet} /// Checks if two Currencys contain equal inner contents. /// This ignores pointers and is_owned flags and looks at the values in fields. #[no_mangle] @@ -1169,6 +1221,24 @@ pub extern "C" fn Fallback_free(this_ptr: Fallback) { } pub extern "C" fn Fallback_clone(orig: &Fallback) -> Fallback { orig.clone() } +#[no_mangle] +/// Utility method to constructs a new SegWitProgram-variant Fallback +pub extern "C" fn Fallback_seg_wit_program(version: crate::c_types::u5, program: crate::c_types::derived::CVec_u8Z) -> Fallback { + Fallback::SegWitProgram { + version, + program, + } +} +#[no_mangle] +/// Utility method to constructs a new PubKeyHash-variant Fallback +pub extern "C" fn Fallback_pub_key_hash(a: crate::c_types::TwentyBytes) -> Fallback { + Fallback::PubKeyHash(a, ) +} +#[no_mangle] +/// Utility method to constructs a new ScriptHash-variant Fallback +pub extern "C" fn Fallback_script_hash(a: crate::c_types::TwentyBytes) -> Fallback { + Fallback::ScriptHash(a, ) +} /// Checks if two Fallbacks contain equal inner contents. /// This ignores pointers and is_owned flags and looks at the values in fields. #[no_mangle] @@ -1387,6 +1457,8 @@ pub extern "C" fn RawInvoice_hash(this_arg: &RawInvoice) -> crate::c_types::Thir crate::c_types::ThirtyTwoBytes { data: ret } } +/// +/// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] pub extern "C" fn RawInvoice_payment_hash(this_arg: &RawInvoice) -> crate::lightning_invoice::Sha256 { @@ -1395,6 +1467,8 @@ pub extern "C" fn RawInvoice_payment_hash(this_arg: &RawInvoice) -> crate::light local_ret } +/// +/// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] pub extern "C" fn RawInvoice_description(this_arg: &RawInvoice) -> crate::lightning_invoice::Description { @@ -1403,6 +1477,8 @@ pub extern "C" fn RawInvoice_description(this_arg: &RawInvoice) -> crate::lightn local_ret } +/// +/// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] pub extern "C" fn RawInvoice_payee_pub_key(this_arg: &RawInvoice) -> crate::lightning_invoice::PayeePubKey { @@ -1411,6 +1487,8 @@ pub extern "C" fn RawInvoice_payee_pub_key(this_arg: &RawInvoice) -> crate::ligh local_ret } +/// +/// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] pub extern "C" fn RawInvoice_description_hash(this_arg: &RawInvoice) -> crate::lightning_invoice::Sha256 { @@ -1419,6 +1497,8 @@ pub extern "C" fn RawInvoice_description_hash(this_arg: &RawInvoice) -> crate::l local_ret } +/// +/// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] pub extern "C" fn RawInvoice_expiry_time(this_arg: &RawInvoice) -> crate::lightning_invoice::ExpiryTime { @@ -1427,6 +1507,8 @@ pub extern "C" fn RawInvoice_expiry_time(this_arg: &RawInvoice) -> crate::lightn local_ret } +/// +/// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] pub extern "C" fn RawInvoice_min_final_cltv_expiry(this_arg: &RawInvoice) -> crate::lightning_invoice::MinFinalCltvExpiry { @@ -1435,6 +1517,8 @@ pub extern "C" fn RawInvoice_min_final_cltv_expiry(this_arg: &RawInvoice) -> cra local_ret } +/// +/// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] pub extern "C" fn RawInvoice_payment_secret(this_arg: &RawInvoice) -> crate::c_types::ThirtyTwoBytes { @@ -1443,6 +1527,8 @@ pub extern "C" fn RawInvoice_payment_secret(this_arg: &RawInvoice) -> crate::c_t local_ret } +/// +/// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] pub extern "C" fn RawInvoice_features(this_arg: &RawInvoice) -> crate::lightning::ln::features::InvoiceFeatures { @@ -1567,6 +1653,8 @@ pub extern "C" fn Invoice_payment_hash(this_arg: &Invoice) -> *const [u8; 32] { } /// Get the payee's public key if one was included in the invoice +/// +/// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] pub extern "C" fn Invoice_payee_pub_key(this_arg: &Invoice) -> crate::c_types::PublicKey { @@ -1576,6 +1664,8 @@ pub extern "C" fn Invoice_payee_pub_key(this_arg: &Invoice) -> crate::c_types::P } /// Get the payment secret if one was included in the invoice +/// +/// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] pub extern "C" fn Invoice_payment_secret(this_arg: &Invoice) -> crate::c_types::ThirtyTwoBytes { @@ -1585,6 +1675,8 @@ pub extern "C" fn Invoice_payment_secret(this_arg: &Invoice) -> crate::c_types:: } /// Get the invoice features if they were included in the invoice +/// +/// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] pub extern "C" fn Invoice_features(this_arg: &Invoice) -> crate::lightning::ln::features::InvoiceFeatures { @@ -1786,6 +1878,22 @@ impl CreationError { pub extern "C" fn CreationError_clone(orig: &CreationError) -> CreationError { orig.clone() } +#[no_mangle] +/// Utility method to constructs a new DescriptionTooLong-variant CreationError +pub extern "C" fn CreationError_description_too_long() -> CreationError { + CreationError::DescriptionTooLong} +#[no_mangle] +/// Utility method to constructs a new RouteTooLong-variant CreationError +pub extern "C" fn CreationError_route_too_long() -> CreationError { + CreationError::RouteTooLong} +#[no_mangle] +/// Utility method to constructs a new TimestampOutOfBounds-variant CreationError +pub extern "C" fn CreationError_timestamp_out_of_bounds() -> CreationError { + CreationError::TimestampOutOfBounds} +#[no_mangle] +/// Utility method to constructs a new ExpiryTimeOutOfBounds-variant CreationError +pub extern "C" fn CreationError_expiry_time_out_of_bounds() -> CreationError { + CreationError::ExpiryTimeOutOfBounds} /// Checks if two CreationErrors contain equal inner contents. /// This ignores pointers and is_owned flags and looks at the values in fields. #[no_mangle] @@ -1880,6 +1988,38 @@ impl SemanticError { pub extern "C" fn SemanticError_clone(orig: &SemanticError) -> SemanticError { orig.clone() } +#[no_mangle] +/// Utility method to constructs a new NoPaymentHash-variant SemanticError +pub extern "C" fn SemanticError_no_payment_hash() -> SemanticError { + SemanticError::NoPaymentHash} +#[no_mangle] +/// Utility method to constructs a new MultiplePaymentHashes-variant SemanticError +pub extern "C" fn SemanticError_multiple_payment_hashes() -> SemanticError { + SemanticError::MultiplePaymentHashes} +#[no_mangle] +/// Utility method to constructs a new NoDescription-variant SemanticError +pub extern "C" fn SemanticError_no_description() -> SemanticError { + SemanticError::NoDescription} +#[no_mangle] +/// Utility method to constructs a new MultipleDescriptions-variant SemanticError +pub extern "C" fn SemanticError_multiple_descriptions() -> SemanticError { + SemanticError::MultipleDescriptions} +#[no_mangle] +/// Utility method to constructs a new MultiplePaymentSecrets-variant SemanticError +pub extern "C" fn SemanticError_multiple_payment_secrets() -> SemanticError { + SemanticError::MultiplePaymentSecrets} +#[no_mangle] +/// Utility method to constructs a new InvalidFeatures-variant SemanticError +pub extern "C" fn SemanticError_invalid_features() -> SemanticError { + SemanticError::InvalidFeatures} +#[no_mangle] +/// Utility method to constructs a new InvalidRecoveryId-variant SemanticError +pub extern "C" fn SemanticError_invalid_recovery_id() -> SemanticError { + SemanticError::InvalidRecoveryId} +#[no_mangle] +/// Utility method to constructs a new InvalidSignature-variant SemanticError +pub extern "C" fn SemanticError_invalid_signature() -> SemanticError { + SemanticError::InvalidSignature} /// Checks if two SemanticErrors contain equal inner contents. /// This ignores pointers and is_owned flags and looks at the values in fields. #[no_mangle] @@ -1969,6 +2109,16 @@ pub extern "C" fn SignOrCreationError_free(this_ptr: SignOrCreationError) { } pub extern "C" fn SignOrCreationError_clone(orig: &SignOrCreationError) -> SignOrCreationError { orig.clone() } +#[no_mangle] +/// Utility method to constructs a new SignError-variant SignOrCreationError +pub extern "C" fn SignOrCreationError_sign_error() -> SignOrCreationError { + SignOrCreationError::SignError +} +#[no_mangle] +/// Utility method to constructs a new CreationError-variant SignOrCreationError +pub extern "C" fn SignOrCreationError_creation_error(a: crate::lightning_invoice::CreationError) -> SignOrCreationError { + SignOrCreationError::CreationError(a, ) +} /// Checks if two SignOrCreationErrors contain equal inner contents. /// This ignores pointers and is_owned flags and looks at the values in fields. #[no_mangle]