3 import CommonBase from './CommonBase';
4 import * as bindings from '../bindings' // TODO: figure out location
8 export default class InvoicePayer extends CommonBase {
9 constructor(_dummy: object, ptr: number) {
14 protected finalize() {
18 bindings.InvoicePayer_free(this.ptr);
21 public static InvoicePayer constructor_new(Payer payer, Router router, MultiThreadedLockableScore scorer, Logger logger, EventHandler event_handler, RetryAttempts retry_attempts) {
22 number ret = bindings.InvoicePayer_new(payer == null ? 0 : payer.ptr, router == null ? 0 : router.ptr, scorer == null ? 0 : scorer.ptr & ~1, logger == null ? 0 : logger.ptr, event_handler == null ? 0 : event_handler.ptr, retry_attempts == null ? 0 : retry_attempts.ptr & ~1);
23 const ret_hu_conv: InvoicePayer = new InvoicePayer(null, ret);
24 ret_hu_conv.ptrs_to.add(ret_hu_conv);
25 ret_hu_conv.ptrs_to.add(payer);
26 ret_hu_conv.ptrs_to.add(router);
27 ret_hu_conv.ptrs_to.add(scorer);
28 ret_hu_conv.ptrs_to.add(logger);
29 ret_hu_conv.ptrs_to.add(event_handler);
33 public Result_PaymentIdPaymentErrorZ pay_invoice(Invoice invoice) {
34 number ret = bindings.InvoicePayer_pay_invoice(this.ptr, invoice == null ? 0 : invoice.ptr & ~1);
35 Result_PaymentIdPaymentErrorZ ret_hu_conv = Result_PaymentIdPaymentErrorZ.constr_from_ptr(ret);
36 this.ptrs_to.add(invoice);
40 public Result_PaymentIdPaymentErrorZ pay_zero_value_invoice(Invoice invoice, number amount_msats) {
41 number ret = bindings.InvoicePayer_pay_zero_value_invoice(this.ptr, invoice == null ? 0 : invoice.ptr & ~1, amount_msats);
42 Result_PaymentIdPaymentErrorZ ret_hu_conv = Result_PaymentIdPaymentErrorZ.constr_from_ptr(ret);
43 this.ptrs_to.add(invoice);
47 public Result_PaymentIdPaymentErrorZ pay_pubkey(Uint8Array pubkey, Uint8Array payment_preimage, number amount_msats, number final_cltv_expiry_delta) {
48 number ret = bindings.InvoicePayer_pay_pubkey(this.ptr, InternalUtils.check_arr_len(pubkey, 33), InternalUtils.check_arr_len(payment_preimage, 32), amount_msats, final_cltv_expiry_delta);
49 Result_PaymentIdPaymentErrorZ ret_hu_conv = Result_PaymentIdPaymentErrorZ.constr_from_ptr(ret);
53 public void remove_cached_payment(Uint8Array payment_hash) {
54 bindings.InvoicePayer_remove_cached_payment(this.ptr, InternalUtils.check_arr_len(payment_hash, 32));
57 public EventHandler as_EventHandler() {
58 number ret = bindings.InvoicePayer_as_EventHandler(this.ptr);
59 EventHandler ret_hu_conv = new EventHandler(null, ret);
60 ret_hu_conv.ptrs_to.add(this);