Update auto-generated bindings
[ldk-java] / ts / structs / SpendableOutputDescriptor.ts
1
2 import CommonBase from './CommonBase';
3 import * as bindings from '../bindings' // TODO: figure out location
4
5 export default class SpendableOutputDescriptor extends CommonBase {
6         protected constructor(_dummy: object, ptr: number) { super(ptr); }
7         protected finalize() {
8                 super.finalize();
9                 if (this.ptr != 0) { bindings.SpendableOutputDescriptor_free(this.ptr); }
10         }
11         static constr_from_ptr(ptr: number): SpendableOutputDescriptor {
12                 const raw_val: bindings.LDKSpendableOutputDescriptor = bindings.LDKSpendableOutputDescriptor_ref_from_ptr(ptr);
13                 if (raw_val instanceof bindings.LDKSpendableOutputDescriptor.StaticOutput) {
14                         return new StaticOutput(this.ptr, raw_val);
15                 }
16                 if (raw_val instanceof bindings.LDKSpendableOutputDescriptor.DelayedPaymentOutput) {
17                         return new DelayedPaymentOutput(this.ptr, raw_val);
18                 }
19                 if (raw_val instanceof bindings.LDKSpendableOutputDescriptor.StaticPaymentOutput) {
20                         return new StaticPaymentOutput(this.ptr, raw_val);
21                 }
22                 throw new Error('oops, this should be unreachable'); // Unreachable without extending the (internal) bindings interface
23         }
24
25 }
26 export class StaticOutput extends SpendableOutputDescriptor {
27         public outpoint: OutPoint;
28         public output: TxOut;
29         private constructor(ptr: number, obj: bindings.LDKSpendableOutputDescriptor.StaticOutput) {
30                 super(null, ptr);
31                 const outpoint: number = obj.outpoint;
32                 const outpoint_hu_conv: OutPoint = new OutPoint(null, outpoint);
33                         outpoint_hu_conv.ptrs_to.add(this);
34                 this.outpoint = outpoint_hu_conv;
35                 const output: number = obj.output;
36                 TxOut output_conv = new TxOut(null, output);
37                 this.output = output_conv;
38         }
39 }
40 export class DelayedPaymentOutput extends SpendableOutputDescriptor {
41         public delayed_payment_output: DelayedPaymentOutputDescriptor;
42         private constructor(ptr: number, obj: bindings.LDKSpendableOutputDescriptor.DelayedPaymentOutput) {
43                 super(null, ptr);
44                 const delayed_payment_output: number = obj.delayed_payment_output;
45                 const delayed_payment_output_hu_conv: DelayedPaymentOutputDescriptor = new DelayedPaymentOutputDescriptor(null, delayed_payment_output);
46                         delayed_payment_output_hu_conv.ptrs_to.add(this);
47                 this.delayed_payment_output = delayed_payment_output_hu_conv;
48         }
49 }
50 export class StaticPaymentOutput extends SpendableOutputDescriptor {
51         public static_payment_output: StaticPaymentOutputDescriptor;
52         private constructor(ptr: number, obj: bindings.LDKSpendableOutputDescriptor.StaticPaymentOutput) {
53                 super(null, ptr);
54                 const static_payment_output: number = obj.static_payment_output;
55                 const static_payment_output_hu_conv: StaticPaymentOutputDescriptor = new StaticPaymentOutputDescriptor(null, static_payment_output);
56                         static_payment_output_hu_conv.ptrs_to.add(this);
57                 this.static_payment_output = static_payment_output_hu_conv;
58         }
59 }
60         public SpendableOutputDescriptor clone() {
61                 number ret = bindings.SpendableOutputDescriptor_clone(this.ptr);
62                 SpendableOutputDescriptor ret_hu_conv = SpendableOutputDescriptor.constr_from_ptr(ret);
63                 ret_hu_conv.ptrs_to.add(this);
64                 return ret_hu_conv;
65         }
66
67         public Uint8Array write() {
68                 Uint8Array ret = bindings.SpendableOutputDescriptor_write(this.ptr);
69                 return ret;
70         }
71
72         public static Result_SpendableOutputDescriptorDecodeErrorZ constructor_read(Uint8Array ser) {
73                 number ret = bindings.SpendableOutputDescriptor_read(ser);
74                 Result_SpendableOutputDescriptorDecodeErrorZ ret_hu_conv = Result_SpendableOutputDescriptorDecodeErrorZ.constr_from_ptr(ret);
75                 return ret_hu_conv;
76         }
77
78 }