UNPKG

lightningdevkit

Version:
140 lines 6.59 kB
import { Option_u64Z } from '../structs/Option_u64Z.mjs'; import { Option_ThirtyTwoBytesZ } from '../structs/Option_ThirtyTwoBytesZ.mjs'; import { Option_u32Z } from '../structs/Option_u32Z.mjs'; import { Option_u16Z } from '../structs/Option_u16Z.mjs'; import { Bolt11InvoiceDescription } from '../structs/Bolt11InvoiceDescription.mjs'; import { CommonBase } from './CommonBase.mjs'; import * as bindings from '../bindings.mjs'; /** * Parameters used with [`create_bolt11_invoice`]. * * [`create_bolt11_invoice`]: ChannelManager::create_bolt11_invoice */ export class Bolt11InvoiceParameters extends CommonBase { /* @internal */ constructor(_dummy, ptr) { super(ptr, bindings.Bolt11InvoiceParameters_free); } /** * The amount for the invoice, if any. */ get_amount_msats() { const ret = bindings.Bolt11InvoiceParameters_get_amount_msats(this.ptr); const ret_hu_conv = Option_u64Z.constr_from_ptr(ret); CommonBase.add_ref_from(ret_hu_conv, this); return ret_hu_conv; } /** * The amount for the invoice, if any. */ set_amount_msats(val) { bindings.Bolt11InvoiceParameters_set_amount_msats(this.ptr, CommonBase.get_ptr_of(val)); } /** * The description for what the invoice is for, or hash of such description. */ get_description() { const ret = bindings.Bolt11InvoiceParameters_get_description(this.ptr); const ret_hu_conv = Bolt11InvoiceDescription.constr_from_ptr(ret); CommonBase.add_ref_from(ret_hu_conv, this); return ret_hu_conv; } /** * The description for what the invoice is for, or hash of such description. */ set_description(val) { bindings.Bolt11InvoiceParameters_set_description(this.ptr, CommonBase.get_ptr_of(val)); } /** * The invoice expiration relative to its creation time. If not set, the invoice will expire in * [`DEFAULT_EXPIRY_TIME`] by default. * * The creation time used is the duration since the Unix epoch for `std` builds. For non-`std` * builds, the highest block timestamp seen is used instead. In the latter case, use a long * enough expiry to account for the average block time. */ get_invoice_expiry_delta_secs() { const ret = bindings.Bolt11InvoiceParameters_get_invoice_expiry_delta_secs(this.ptr); const ret_hu_conv = Option_u32Z.constr_from_ptr(ret); CommonBase.add_ref_from(ret_hu_conv, this); return ret_hu_conv; } /** * The invoice expiration relative to its creation time. If not set, the invoice will expire in * [`DEFAULT_EXPIRY_TIME`] by default. * * The creation time used is the duration since the Unix epoch for `std` builds. For non-`std` * builds, the highest block timestamp seen is used instead. In the latter case, use a long * enough expiry to account for the average block time. */ set_invoice_expiry_delta_secs(val) { bindings.Bolt11InvoiceParameters_set_invoice_expiry_delta_secs(this.ptr, CommonBase.get_ptr_of(val)); } /** * The minimum `cltv_expiry` for the last HTLC in the route. If not set, will use * [`MIN_FINAL_CLTV_EXPIRY_DELTA`]. * * If set, must be at least [`MIN_FINAL_CLTV_EXPIRY_DELTA`], and a three-block buffer will be * added as well to allow for up to a few new block confirmations during routing. */ get_min_final_cltv_expiry_delta() { const ret = bindings.Bolt11InvoiceParameters_get_min_final_cltv_expiry_delta(this.ptr); const ret_hu_conv = Option_u16Z.constr_from_ptr(ret); CommonBase.add_ref_from(ret_hu_conv, this); return ret_hu_conv; } /** * The minimum `cltv_expiry` for the last HTLC in the route. If not set, will use * [`MIN_FINAL_CLTV_EXPIRY_DELTA`]. * * If set, must be at least [`MIN_FINAL_CLTV_EXPIRY_DELTA`], and a three-block buffer will be * added as well to allow for up to a few new block confirmations during routing. */ set_min_final_cltv_expiry_delta(val) { bindings.Bolt11InvoiceParameters_set_min_final_cltv_expiry_delta(this.ptr, CommonBase.get_ptr_of(val)); } /** * The payment hash used in the invoice. If not set, a payment hash will be generated using a * preimage that can be reproduced by [`ChannelManager`] without storing any state. * * Uses the payment hash if set. This may be useful if you're building an on-chain swap or * involving another protocol where the payment hash is also involved outside the scope of * lightning. */ get_payment_hash() { const ret = bindings.Bolt11InvoiceParameters_get_payment_hash(this.ptr); const ret_hu_conv = Option_ThirtyTwoBytesZ.constr_from_ptr(ret); CommonBase.add_ref_from(ret_hu_conv, this); return ret_hu_conv; } /** * The payment hash used in the invoice. If not set, a payment hash will be generated using a * preimage that can be reproduced by [`ChannelManager`] without storing any state. * * Uses the payment hash if set. This may be useful if you're building an on-chain swap or * involving another protocol where the payment hash is also involved outside the scope of * lightning. */ set_payment_hash(val) { bindings.Bolt11InvoiceParameters_set_payment_hash(this.ptr, CommonBase.get_ptr_of(val)); } /** * Constructs a new Bolt11InvoiceParameters given each field */ static constructor_new(amount_msats_arg, description_arg, invoice_expiry_delta_secs_arg, min_final_cltv_expiry_delta_arg, payment_hash_arg) { const ret = bindings.Bolt11InvoiceParameters_new(CommonBase.get_ptr_of(amount_msats_arg), CommonBase.get_ptr_of(description_arg), CommonBase.get_ptr_of(invoice_expiry_delta_secs_arg), CommonBase.get_ptr_of(min_final_cltv_expiry_delta_arg), CommonBase.get_ptr_of(payment_hash_arg)); const ret_hu_conv = new Bolt11InvoiceParameters(null, ret); CommonBase.add_ref_from(ret_hu_conv, ret_hu_conv); return ret_hu_conv; } /** * Creates a "default" Bolt11InvoiceParameters. See struct and individual field documentaiton for details on which values are used. */ static constructor_default() { const ret = bindings.Bolt11InvoiceParameters_default(); const ret_hu_conv = new Bolt11InvoiceParameters(null, ret); CommonBase.add_ref_from(ret_hu_conv, ret_hu_conv); return ret_hu_conv; } } //# sourceMappingURL=Bolt11InvoiceParameters.mjs.map