UNPKG

lightningdevkit

Version:
73 lines 3.2 kB
import { Result_Bolt12InvoiceBolt12SemanticErrorZ } from '../structs/Result_Bolt12InvoiceBolt12SemanticErrorZ.mjs'; import { CommonBase } from './CommonBase.mjs'; import * as bindings from '../bindings.mjs'; /** * Builds a [`Bolt12Invoice`] from either: * - an [`InvoiceRequest`] for the \"offer to be paid\" flow or * - a [`Refund`] for the \"offer for money\" flow. * * See [module-level documentation] for usage. * * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest * [`Refund`]: crate::offers::refund::Refund * [module-level documentation]: self */ export class InvoiceWithDerivedSigningPubkeyBuilder extends CommonBase { /* @internal */ constructor(_dummy, ptr) { super(ptr, bindings.InvoiceWithDerivedSigningPubkeyBuilder_free); } /** * Builds a signed [`Bolt12Invoice`] after checking for valid semantics. */ build_and_sign() { const ret = bindings.InvoiceWithDerivedSigningPubkeyBuilder_build_and_sign(this.ptr); const ret_hu_conv = Result_Bolt12InvoiceBolt12SemanticErrorZ.constr_from_ptr(ret); return ret_hu_conv; } /** * Sets the [`Bolt12Invoice::relative_expiry`] * as seconds since [`Bolt12Invoice::created_at`]. * Any expiry that has already passed is valid and can be checked for using * * Successive calls to this method will override the previous setting. */ relative_expiry(relative_expiry_secs) { bindings.InvoiceWithDerivedSigningPubkeyBuilder_relative_expiry(this.ptr, relative_expiry_secs); } /** * Adds a P2WSH address to [`Bolt12Invoice::fallbacks`]. * * Successive calls to this method will add another address. Caller is responsible for not * adding duplicate addresses and only calling if capable of receiving to P2WSH addresses. */ fallback_v0_p2wsh(script_hash) { bindings.InvoiceWithDerivedSigningPubkeyBuilder_fallback_v0_p2wsh(this.ptr, bindings.encodeUint8Array(script_hash)); } /** * Adds a P2WPKH address to [`Bolt12Invoice::fallbacks`]. * * Successive calls to this method will add another address. Caller is responsible for not * adding duplicate addresses and only calling if capable of receiving to P2WPKH addresses. */ fallback_v0_p2wpkh(pubkey_hash) { bindings.InvoiceWithDerivedSigningPubkeyBuilder_fallback_v0_p2wpkh(this.ptr, bindings.encodeUint8Array(pubkey_hash)); } /** * Adds a P2TR address to [`Bolt12Invoice::fallbacks`]. * * Successive calls to this method will add another address. Caller is responsible for not * adding duplicate addresses and only calling if capable of receiving to P2TR addresses. */ fallback_v1_p2tr_tweaked(utput_key) { bindings.InvoiceWithDerivedSigningPubkeyBuilder_fallback_v1_p2tr_tweaked(this.ptr, bindings.encodeUint8Array(utput_key)); } /** * Sets [`Bolt12Invoice::invoice_features`] * to indicate MPP may be used. Otherwise, MPP is disallowed. */ allow_mpp() { bindings.InvoiceWithDerivedSigningPubkeyBuilder_allow_mpp(this.ptr); } } //# sourceMappingURL=InvoiceWithDerivedSigningPubkeyBuilder.mjs.map