]> git.bitcoin.ninja Git - ldk-java/blob - ts/structs/PaymentPurpose.ts
Update auto-generate bindings (incl new RL clone methods)
[ldk-java] / ts / structs / PaymentPurpose.ts
1
2 import CommonBase from './CommonBase';
3 import * as bindings from '../bindings' // TODO: figure out location
4
5 export default class PaymentPurpose extends CommonBase {
6         protected constructor(_dummy: object, ptr: number) { super(ptr); }
7         protected finalize() {
8                 super.finalize();
9                 if (this.ptr != 0) { bindings.PaymentPurpose_free(this.ptr); }
10         }
11         static constr_from_ptr(ptr: number): PaymentPurpose {
12                 const raw_val: bindings.LDKPaymentPurpose = bindings.LDKPaymentPurpose_ref_from_ptr(ptr);
13                 if (raw_val instanceof bindings.LDKPaymentPurpose.InvoicePayment) {
14                         return new InvoicePayment(this.ptr, raw_val);
15                 }
16                 if (raw_val instanceof bindings.LDKPaymentPurpose.SpontaneousPayment) {
17                         return new SpontaneousPayment(this.ptr, raw_val);
18                 }
19                 throw new Error('oops, this should be unreachable'); // Unreachable without extending the (internal) bindings interface
20         }
21
22 }
23 export class InvoicePayment extends PaymentPurpose {
24         public payment_preimage: Uint8Array;
25         public payment_secret: Uint8Array;
26         public user_payment_id: number;
27         private constructor(ptr: number, obj: bindings.LDKPaymentPurpose.InvoicePayment) {
28                 super(null, ptr);
29                 this.payment_preimage = obj.payment_preimage;
30                 this.payment_secret = obj.payment_secret;
31                 this.user_payment_id = obj.user_payment_id;
32         }
33 }
34 export class SpontaneousPayment extends PaymentPurpose {
35         public spontaneous_payment: Uint8Array;
36         private constructor(ptr: number, obj: bindings.LDKPaymentPurpose.SpontaneousPayment) {
37                 super(null, ptr);
38                 this.spontaneous_payment = obj.spontaneous_payment;
39         }
40 }
41         public PaymentPurpose clone() {
42                 number ret = bindings.PaymentPurpose_clone(this.ptr);
43                 PaymentPurpose ret_hu_conv = PaymentPurpose.constr_from_ptr(ret);
44                 ret_hu_conv.ptrs_to.add(this);
45                 return ret_hu_conv;
46         }
47
48         public static PaymentPurpose constructor_invoice_payment(Uint8Array payment_preimage, Uint8Array payment_secret, number user_payment_id) {
49                 number ret = bindings.PaymentPurpose_invoice_payment(payment_preimage, payment_secret, user_payment_id);
50                 PaymentPurpose ret_hu_conv = PaymentPurpose.constr_from_ptr(ret);
51                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
52                 return ret_hu_conv;
53         }
54
55         public static PaymentPurpose constructor_spontaneous_payment(Uint8Array a) {
56                 number ret = bindings.PaymentPurpose_spontaneous_payment(a);
57                 PaymentPurpose ret_hu_conv = PaymentPurpose.constr_from_ptr(ret);
58                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
59                 return ret_hu_conv;
60         }
61
62 }