UNPKG

lightningdevkit

Version:
46 lines 1.88 kB
import { UnsignedBolt12Invoice } from '../structs/UnsignedBolt12Invoice.mjs'; import { Result_SchnorrSignatureNoneZ } from '../structs/Result_SchnorrSignatureNoneZ.mjs'; import { CommonBase } from './CommonBase.mjs'; import * as bindings from '../bindings.mjs'; class LDKSignBolt12InvoiceFnHolder { constructor() { this.held = null; } } /** * A function for signing an [`UnsignedBolt12Invoice`]. */ export class SignBolt12InvoiceFn extends CommonBase { /* @internal */ constructor(_dummy, ptr) { super(ptr, bindings.SignBolt12InvoiceFn_free); this.bindings_instance = null; } /** Creates a new instance of SignBolt12InvoiceFn from a given implementation */ static new_impl(arg) { const impl_holder = new LDKSignBolt12InvoiceFnHolder(); let structImplementation = { sign_invoice(message) { const message_hu_conv = new UnsignedBolt12Invoice(null, message); const ret = arg.sign_invoice(message_hu_conv); const result = ret.clone_ptr(); return result; }, }; const ptr_idx = bindings.LDKSignBolt12InvoiceFn_new(structImplementation); impl_holder.held = new SignBolt12InvoiceFn(null, ptr_idx[0]); impl_holder.held.instance_idx = ptr_idx[1]; impl_holder.held.bindings_instance = structImplementation; return impl_holder.held; } /** * Signs a [`TaggedHash`] computed over the merkle root of `message`'s TLV stream. */ sign_invoice(message) { const ret = bindings.SignBolt12InvoiceFn_sign_invoice(this.ptr, CommonBase.get_ptr_of(message)); const ret_hu_conv = Result_SchnorrSignatureNoneZ.constr_from_ptr(ret); CommonBase.add_ref_from(this, message); return ret_hu_conv; } } //# sourceMappingURL=SignBolt12InvoiceFn.mjs.map