X-Git-Url: http://git.bitcoin.ninja/index.cgi?p=ldk-c-bindings;a=blobdiff_plain;f=lightning-c-bindings%2Finclude%2Flightning.h;h=ee15c0f2ee797b439aa36d3a5a7771285dcaafb3;hp=ac086be8eb562b667066621c342136cae53ae403;hb=4e715a943a67a3c846cc8af185b59cb24a4e8ae2;hpb=6bcd3f1f7b2934c12a25d5a98bee1d474f670861 diff --git a/lightning-c-bindings/include/lightning.h b/lightning-c-bindings/include/lightning.h index ac086be..ee15c0f 100644 --- a/lightning-c-bindings/include/lightning.h +++ b/lightning-c-bindings/include/lightning.h @@ -1,7 +1,7 @@ #ifndef LDK_C_BINDINGS_H #define LDK_C_BINDINGS_H -/* Generated with cbindgen:0.17.0 */ +/* Generated with cbindgen:0.20.0 */ /* Warning, this file is autogenerated by cbindgen. Don't modify this manually. */ @@ -7132,36 +7132,151 @@ typedef struct LDKCResult_PaymentIdPaymentErrorZ { } LDKCResult_PaymentIdPaymentErrorZ; /** - * The contents of CResult_SiPrefixNoneZ + * Represents an error returned from the bech32 library during validation of some bech32 data */ -typedef union LDKCResult_SiPrefixNoneZPtr { +typedef enum LDKBech32Error_Tag { + /** + * String does not contain the separator character + */ + LDKBech32Error_MissingSeparator, + /** + * The checksum does not match the rest of the data + */ + LDKBech32Error_InvalidChecksum, + /** + * The data or human-readable part is too long or too short + */ + LDKBech32Error_InvalidLength, + /** + * Some part of the string contains an invalid character + */ + LDKBech32Error_InvalidChar, + /** + * Some part of the data has an invalid value + */ + LDKBech32Error_InvalidData, + /** + * The bit conversion failed due to a padding issue + */ + LDKBech32Error_InvalidPadding, + /** + * The whole string must be of one case + */ + LDKBech32Error_MixedCase, + /** + * Must be last for serialization purposes + */ + LDKBech32Error_Sentinel, +} LDKBech32Error_Tag; + +typedef struct LDKBech32Error { + LDKBech32Error_Tag tag; + union { + struct { + uint32_t invalid_char; + }; + struct { + uint8_t invalid_data; + }; + }; +} LDKBech32Error; + +/** + * Sub-errors which don't have specific information in them use this type. + */ +typedef struct LDKError { + /** + * Zero-Sized_types aren't consistent across Rust/C/C++, so we add some size here + */ + uint8_t _dummy; +} LDKError; + +/** + * Errors that indicate what is wrong with the invoice. They have some granularity for debug + * reasons, but should generally result in an \"invalid BOLT11 invoice\" message for the user. + */ +typedef enum LDKParseError_Tag { + LDKParseError_Bech32Error, + LDKParseError_ParseAmountError, + LDKParseError_MalformedSignature, + LDKParseError_BadPrefix, + LDKParseError_UnknownCurrency, + LDKParseError_UnknownSiPrefix, + LDKParseError_MalformedHRP, + LDKParseError_TooShortDataPart, + LDKParseError_UnexpectedEndOfTaggedFields, + LDKParseError_DescriptionDecodeError, + LDKParseError_PaddingError, + LDKParseError_IntegerOverflowError, + LDKParseError_InvalidSegWitProgramLength, + LDKParseError_InvalidPubKeyHashLength, + LDKParseError_InvalidScriptHashLength, + LDKParseError_InvalidRecoveryId, + LDKParseError_InvalidSliceLength, + /** + * Not an error, but used internally to signal that a part of the invoice should be ignored + * according to BOLT11 + */ + LDKParseError_Skip, + /** + * Must be last for serialization purposes + */ + LDKParseError_Sentinel, +} LDKParseError_Tag; + +typedef struct MUST_USE_STRUCT LDKParseError { + LDKParseError_Tag tag; + union { + struct { + struct LDKBech32Error bech32_error; + }; + struct { + struct LDKError parse_amount_error; + }; + struct { + enum LDKSecp256k1Error malformed_signature; + }; + struct { + struct LDKError description_decode_error; + }; + struct { + struct LDKStr invalid_slice_length; + }; + }; +} LDKParseError; + +/** + * The contents of CResult_SiPrefixParseErrorZ + */ +typedef union LDKCResult_SiPrefixParseErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ enum LDKSiPrefix *result; /** - * Note that this value is always NULL, as there are no contents in the Err variant + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - void *err; -} LDKCResult_SiPrefixNoneZPtr; + struct LDKParseError *err; +} LDKCResult_SiPrefixParseErrorZPtr; /** - * A CResult_SiPrefixNoneZ represents the result of a fallible operation, - * containing a crate::lightning_invoice::SiPrefix on success and a () on failure. + * A CResult_SiPrefixParseErrorZ represents the result of a fallible operation, + * containing a crate::lightning_invoice::SiPrefix on success and a crate::lightning_invoice::ParseError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_SiPrefixNoneZ { +typedef struct LDKCResult_SiPrefixParseErrorZ { /** - * The contents of this CResult_SiPrefixNoneZ, accessible via either + * The contents of this CResult_SiPrefixParseErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_SiPrefixNoneZPtr contents; + union LDKCResult_SiPrefixParseErrorZPtr contents; /** - * Whether this CResult_SiPrefixNoneZ represents a success state. + * Whether this CResult_SiPrefixParseErrorZ represents a success state. */ bool result_ok; -} LDKCResult_SiPrefixNoneZ; +} LDKCResult_SiPrefixParseErrorZ; @@ -7189,36 +7304,69 @@ typedef struct MUST_USE_STRUCT LDKInvoice { } LDKInvoice; /** - * The contents of CResult_InvoiceNoneZ + * Indicates that something went wrong while parsing or validating the invoice. Parsing errors + * should be mostly seen as opaque and are only there for debugging reasons. Semantic errors + * like wrong signatures, missing fields etc. could mean that someone tampered with the invoice. + */ +typedef enum LDKParseOrSemanticError_Tag { + /** + * The invoice couldn't be decoded + */ + LDKParseOrSemanticError_ParseError, + /** + * The invoice could be decoded but violates the BOLT11 standard + */ + LDKParseOrSemanticError_SemanticError, + /** + * Must be last for serialization purposes + */ + LDKParseOrSemanticError_Sentinel, +} LDKParseOrSemanticError_Tag; + +typedef struct MUST_USE_STRUCT LDKParseOrSemanticError { + LDKParseOrSemanticError_Tag tag; + union { + struct { + struct LDKParseError parse_error; + }; + struct { + enum LDKSemanticError semantic_error; + }; + }; +} LDKParseOrSemanticError; + +/** + * The contents of CResult_InvoiceParseOrSemanticErrorZ */ -typedef union LDKCResult_InvoiceNoneZPtr { +typedef union LDKCResult_InvoiceParseOrSemanticErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ struct LDKInvoice *result; /** - * Note that this value is always NULL, as there are no contents in the Err variant + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - void *err; -} LDKCResult_InvoiceNoneZPtr; + struct LDKParseOrSemanticError *err; +} LDKCResult_InvoiceParseOrSemanticErrorZPtr; /** - * A CResult_InvoiceNoneZ represents the result of a fallible operation, - * containing a crate::lightning_invoice::Invoice on success and a () on failure. + * A CResult_InvoiceParseOrSemanticErrorZ represents the result of a fallible operation, + * containing a crate::lightning_invoice::Invoice on success and a crate::lightning_invoice::ParseOrSemanticError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_InvoiceNoneZ { +typedef struct LDKCResult_InvoiceParseOrSemanticErrorZ { /** - * The contents of this CResult_InvoiceNoneZ, accessible via either + * The contents of this CResult_InvoiceParseOrSemanticErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_InvoiceNoneZPtr contents; + union LDKCResult_InvoiceParseOrSemanticErrorZPtr contents; /** - * Whether this CResult_InvoiceNoneZ represents a success state. + * Whether this CResult_InvoiceParseOrSemanticErrorZ represents a success state. */ bool result_ok; -} LDKCResult_InvoiceNoneZ; +} LDKCResult_InvoiceParseOrSemanticErrorZ; @@ -7245,36 +7393,37 @@ typedef struct MUST_USE_STRUCT LDKSignedRawInvoice { } LDKSignedRawInvoice; /** - * The contents of CResult_SignedRawInvoiceNoneZ + * The contents of CResult_SignedRawInvoiceParseErrorZ */ -typedef union LDKCResult_SignedRawInvoiceNoneZPtr { +typedef union LDKCResult_SignedRawInvoiceParseErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ struct LDKSignedRawInvoice *result; /** - * Note that this value is always NULL, as there are no contents in the Err variant + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - void *err; -} LDKCResult_SignedRawInvoiceNoneZPtr; + struct LDKParseError *err; +} LDKCResult_SignedRawInvoiceParseErrorZPtr; /** - * A CResult_SignedRawInvoiceNoneZ represents the result of a fallible operation, - * containing a crate::lightning_invoice::SignedRawInvoice on success and a () on failure. + * A CResult_SignedRawInvoiceParseErrorZ represents the result of a fallible operation, + * containing a crate::lightning_invoice::SignedRawInvoice on success and a crate::lightning_invoice::ParseError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_SignedRawInvoiceNoneZ { +typedef struct LDKCResult_SignedRawInvoiceParseErrorZ { /** - * The contents of this CResult_SignedRawInvoiceNoneZ, accessible via either + * The contents of this CResult_SignedRawInvoiceParseErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_SignedRawInvoiceNoneZPtr contents; + union LDKCResult_SignedRawInvoiceParseErrorZPtr contents; /** - * Whether this CResult_SignedRawInvoiceNoneZ represents a success state. + * Whether this CResult_SignedRawInvoiceParseErrorZ represents a success state. */ bool result_ok; -} LDKCResult_SignedRawInvoiceNoneZ; +} LDKCResult_SignedRawInvoiceParseErrorZ; @@ -14514,82 +14663,82 @@ void CResult_PaymentIdPaymentErrorZ_free(struct LDKCResult_PaymentIdPaymentError struct LDKCResult_PaymentIdPaymentErrorZ CResult_PaymentIdPaymentErrorZ_clone(const struct LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_SiPrefixNoneZ in the success state. + * Creates a new CResult_SiPrefixParseErrorZ in the success state. */ -struct LDKCResult_SiPrefixNoneZ CResult_SiPrefixNoneZ_ok(enum LDKSiPrefix o); +struct LDKCResult_SiPrefixParseErrorZ CResult_SiPrefixParseErrorZ_ok(enum LDKSiPrefix o); /** - * Creates a new CResult_SiPrefixNoneZ in the error state. + * Creates a new CResult_SiPrefixParseErrorZ in the error state. */ -struct LDKCResult_SiPrefixNoneZ CResult_SiPrefixNoneZ_err(void); +struct LDKCResult_SiPrefixParseErrorZ CResult_SiPrefixParseErrorZ_err(struct LDKParseError e); /** * Checks if the given object is currently in the success state */ -bool CResult_SiPrefixNoneZ_is_ok(const struct LDKCResult_SiPrefixNoneZ *NONNULL_PTR o); +bool CResult_SiPrefixParseErrorZ_is_ok(const struct LDKCResult_SiPrefixParseErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_SiPrefixNoneZ. + * Frees any resources used by the CResult_SiPrefixParseErrorZ. */ -void CResult_SiPrefixNoneZ_free(struct LDKCResult_SiPrefixNoneZ _res); +void CResult_SiPrefixParseErrorZ_free(struct LDKCResult_SiPrefixParseErrorZ _res); /** - * Creates a new CResult_SiPrefixNoneZ which has the same data as `orig` + * Creates a new CResult_SiPrefixParseErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_SiPrefixNoneZ CResult_SiPrefixNoneZ_clone(const struct LDKCResult_SiPrefixNoneZ *NONNULL_PTR orig); +struct LDKCResult_SiPrefixParseErrorZ CResult_SiPrefixParseErrorZ_clone(const struct LDKCResult_SiPrefixParseErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_InvoiceNoneZ in the success state. + * Creates a new CResult_InvoiceParseOrSemanticErrorZ in the success state. */ -struct LDKCResult_InvoiceNoneZ CResult_InvoiceNoneZ_ok(struct LDKInvoice o); +struct LDKCResult_InvoiceParseOrSemanticErrorZ CResult_InvoiceParseOrSemanticErrorZ_ok(struct LDKInvoice o); /** - * Creates a new CResult_InvoiceNoneZ in the error state. + * Creates a new CResult_InvoiceParseOrSemanticErrorZ in the error state. */ -struct LDKCResult_InvoiceNoneZ CResult_InvoiceNoneZ_err(void); +struct LDKCResult_InvoiceParseOrSemanticErrorZ CResult_InvoiceParseOrSemanticErrorZ_err(struct LDKParseOrSemanticError e); /** * Checks if the given object is currently in the success state */ -bool CResult_InvoiceNoneZ_is_ok(const struct LDKCResult_InvoiceNoneZ *NONNULL_PTR o); +bool CResult_InvoiceParseOrSemanticErrorZ_is_ok(const struct LDKCResult_InvoiceParseOrSemanticErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_InvoiceNoneZ. + * Frees any resources used by the CResult_InvoiceParseOrSemanticErrorZ. */ -void CResult_InvoiceNoneZ_free(struct LDKCResult_InvoiceNoneZ _res); +void CResult_InvoiceParseOrSemanticErrorZ_free(struct LDKCResult_InvoiceParseOrSemanticErrorZ _res); /** - * Creates a new CResult_InvoiceNoneZ which has the same data as `orig` + * Creates a new CResult_InvoiceParseOrSemanticErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_InvoiceNoneZ CResult_InvoiceNoneZ_clone(const struct LDKCResult_InvoiceNoneZ *NONNULL_PTR orig); +struct LDKCResult_InvoiceParseOrSemanticErrorZ CResult_InvoiceParseOrSemanticErrorZ_clone(const struct LDKCResult_InvoiceParseOrSemanticErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_SignedRawInvoiceNoneZ in the success state. + * Creates a new CResult_SignedRawInvoiceParseErrorZ in the success state. */ -struct LDKCResult_SignedRawInvoiceNoneZ CResult_SignedRawInvoiceNoneZ_ok(struct LDKSignedRawInvoice o); +struct LDKCResult_SignedRawInvoiceParseErrorZ CResult_SignedRawInvoiceParseErrorZ_ok(struct LDKSignedRawInvoice o); /** - * Creates a new CResult_SignedRawInvoiceNoneZ in the error state. + * Creates a new CResult_SignedRawInvoiceParseErrorZ in the error state. */ -struct LDKCResult_SignedRawInvoiceNoneZ CResult_SignedRawInvoiceNoneZ_err(void); +struct LDKCResult_SignedRawInvoiceParseErrorZ CResult_SignedRawInvoiceParseErrorZ_err(struct LDKParseError e); /** * Checks if the given object is currently in the success state */ -bool CResult_SignedRawInvoiceNoneZ_is_ok(const struct LDKCResult_SignedRawInvoiceNoneZ *NONNULL_PTR o); +bool CResult_SignedRawInvoiceParseErrorZ_is_ok(const struct LDKCResult_SignedRawInvoiceParseErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_SignedRawInvoiceNoneZ. + * Frees any resources used by the CResult_SignedRawInvoiceParseErrorZ. */ -void CResult_SignedRawInvoiceNoneZ_free(struct LDKCResult_SignedRawInvoiceNoneZ _res); +void CResult_SignedRawInvoiceParseErrorZ_free(struct LDKCResult_SignedRawInvoiceParseErrorZ _res); /** - * Creates a new CResult_SignedRawInvoiceNoneZ which has the same data as `orig` + * Creates a new CResult_SignedRawInvoiceParseErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_SignedRawInvoiceNoneZ CResult_SignedRawInvoiceNoneZ_clone(const struct LDKCResult_SignedRawInvoiceNoneZ *NONNULL_PTR orig); +struct LDKCResult_SignedRawInvoiceParseErrorZ CResult_SignedRawInvoiceParseErrorZ_clone(const struct LDKCResult_SignedRawInvoiceParseErrorZ *NONNULL_PTR orig); /** * Creates a new tuple which has the same data as `orig` @@ -25858,6 +26007,126 @@ MUST_USE_RES struct LDKCResult_NoneErrorZ BackgroundProcessor_join(struct LDKBac */ MUST_USE_RES struct LDKCResult_NoneErrorZ BackgroundProcessor_stop(struct LDKBackgroundProcessor this_arg); +/** + * Frees any resources used by the ParseError + */ +void ParseError_free(struct LDKParseError this_ptr); + +/** + * Creates a copy of the ParseError + */ +struct LDKParseError ParseError_clone(const struct LDKParseError *NONNULL_PTR orig); + +/** + * Utility method to constructs a new Bech32Error-variant ParseError + */ +struct LDKParseError ParseError_bech32_error(struct LDKBech32Error a); + +/** + * Utility method to constructs a new ParseAmountError-variant ParseError + */ +struct LDKParseError ParseError_parse_amount_error(struct LDKError a); + +/** + * Utility method to constructs a new MalformedSignature-variant ParseError + */ +struct LDKParseError ParseError_malformed_signature(enum LDKSecp256k1Error a); + +/** + * Utility method to constructs a new BadPrefix-variant ParseError + */ +struct LDKParseError ParseError_bad_prefix(void); + +/** + * Utility method to constructs a new UnknownCurrency-variant ParseError + */ +struct LDKParseError ParseError_unknown_currency(void); + +/** + * Utility method to constructs a new UnknownSiPrefix-variant ParseError + */ +struct LDKParseError ParseError_unknown_si_prefix(void); + +/** + * Utility method to constructs a new MalformedHRP-variant ParseError + */ +struct LDKParseError ParseError_malformed_hrp(void); + +/** + * Utility method to constructs a new TooShortDataPart-variant ParseError + */ +struct LDKParseError ParseError_too_short_data_part(void); + +/** + * Utility method to constructs a new UnexpectedEndOfTaggedFields-variant ParseError + */ +struct LDKParseError ParseError_unexpected_end_of_tagged_fields(void); + +/** + * Utility method to constructs a new DescriptionDecodeError-variant ParseError + */ +struct LDKParseError ParseError_description_decode_error(struct LDKError a); + +/** + * Utility method to constructs a new PaddingError-variant ParseError + */ +struct LDKParseError ParseError_padding_error(void); + +/** + * Utility method to constructs a new IntegerOverflowError-variant ParseError + */ +struct LDKParseError ParseError_integer_overflow_error(void); + +/** + * Utility method to constructs a new InvalidSegWitProgramLength-variant ParseError + */ +struct LDKParseError ParseError_invalid_seg_wit_program_length(void); + +/** + * Utility method to constructs a new InvalidPubKeyHashLength-variant ParseError + */ +struct LDKParseError ParseError_invalid_pub_key_hash_length(void); + +/** + * Utility method to constructs a new InvalidScriptHashLength-variant ParseError + */ +struct LDKParseError ParseError_invalid_script_hash_length(void); + +/** + * Utility method to constructs a new InvalidRecoveryId-variant ParseError + */ +struct LDKParseError ParseError_invalid_recovery_id(void); + +/** + * Utility method to constructs a new InvalidSliceLength-variant ParseError + */ +struct LDKParseError ParseError_invalid_slice_length(struct LDKStr a); + +/** + * Utility method to constructs a new Skip-variant ParseError + */ +struct LDKParseError ParseError_skip(void); + +/** + * Frees any resources used by the ParseOrSemanticError + */ +void ParseOrSemanticError_free(struct LDKParseOrSemanticError this_ptr); + +/** + * Creates a copy of the ParseOrSemanticError + */ +struct LDKParseOrSemanticError ParseOrSemanticError_clone(const struct LDKParseOrSemanticError *NONNULL_PTR orig); + +/** + * Utility method to constructs a new ParseError-variant ParseOrSemanticError + */ +struct LDKParseOrSemanticError ParseOrSemanticError_parse_error(struct LDKParseError a); + +/** + * Utility method to constructs a new SemanticError-variant ParseOrSemanticError + */ +struct LDKParseOrSemanticError ParseOrSemanticError_semantic_error(enum LDKSemanticError a); + /** * Frees any resources used by the Invoice, if is_owned is set and inner is non-NULL. */ @@ -26909,17 +27178,27 @@ struct LDKPayer ChannelManager_as_Payer(const struct LDKChannelManager *NONNULL_ /** * Read a SiPrefix object from a string */ -struct LDKCResult_SiPrefixNoneZ SiPrefix_from_str(struct LDKStr s); +struct LDKCResult_SiPrefixParseErrorZ SiPrefix_from_str(struct LDKStr s); /** * Read a Invoice object from a string */ -struct LDKCResult_InvoiceNoneZ Invoice_from_str(struct LDKStr s); +struct LDKCResult_InvoiceParseOrSemanticErrorZ Invoice_from_str(struct LDKStr s); /** * Read a SignedRawInvoice object from a string */ -struct LDKCResult_SignedRawInvoiceNoneZ SignedRawInvoice_from_str(struct LDKStr s); +struct LDKCResult_SignedRawInvoiceParseErrorZ SignedRawInvoice_from_str(struct LDKStr s); + +/** + * Get the string representation of a ParseError object + */ +struct LDKStr ParseError_to_str(const struct LDKParseError *NONNULL_PTR o); + +/** + * Get the string representation of a ParseOrSemanticError object + */ +struct LDKStr ParseOrSemanticError_to_str(const struct LDKParseOrSemanticError *NONNULL_PTR o); /** * Get the string representation of a Invoice object