Merge pull request #46 from TheBlueMatt/main
[ldk-java] / ts / structs / Confirm.ts
1
2             
3 import CommonBase from './CommonBase';
4 import * as bindings from '../bindings' // TODO: figure out location
5
6
7
8             export class Confirm extends CommonBase {
9
10                 bindings_instance?: bindings.LDKConfirm;
11
12                 constructor(ptr?: number, arg?: bindings.LDKConfirm) {
13                     if (Number.isFinite(ptr)) {
14                                         super(ptr);
15                                         this.bindings_instance = null;
16                                     } else {
17                                         // TODO: private constructor instantiation
18                                         super(bindings.LDKConfirm_new(arg));
19                                         this.ptrs_to.push(arg);
20                                         
21                                     }
22                 }
23
24                 protected finalize() {
25                     if (this.ptr != 0) {
26                         bindings.Confirm_free(this.ptr);
27                     }
28                     super.finalize();
29                 }
30
31                 static new_impl(arg: ConfirmInterface): Confirm {
32                     const impl_holder: LDKConfirmHolder = new LDKConfirmHolder();
33                     let structImplementation = <bindings.LDKConfirm>{
34                         // todo: in-line interface filling
35                         transactions_confirmed (header: Uint8Array, txdata: number[], height: number): void {
36                                                         TwoTuple_usizeTransactionZ[] txdata_conv_28_arr = new TwoTuple_usizeTransactionZ[txdata.length];
37                                 for (int c = 0; c < txdata.length; c++) {
38                                         number txdata_conv_28 = txdata[c];
39                                         TwoTuple_usizeTransactionZ txdata_conv_28_hu_conv = new TwoTuple_usizeTransactionZ(null, txdata_conv_28);
40                                         txdata_conv_28_hu_conv.ptrs_to.add(this);
41                                         txdata_conv_28_arr[c] = txdata_conv_28_hu_conv;
42                                 }
43                                                         arg.transactions_confirmed(header, txdata_conv_28_arr, height);
44                                                 },
45
46                                                 transaction_unconfirmed (txid: Uint8Array): void {
47                                                         arg.transaction_unconfirmed(txid);
48                                                 },
49
50                                                 best_block_updated (header: Uint8Array, height: number): void {
51                                                         arg.best_block_updated(header, height);
52                                                 },
53
54                                                 get_relevant_txids (): Uint8Array[] {
55                                                         Uint8Array[] ret = arg.get_relevant_txids();
56                                 return ret;
57                                                 },
58
59                                                 
60                     };
61                     impl_holder.held = new Confirm (null, structImplementation);
62                 }
63             }
64
65             export interface ConfirmInterface {
66                 transactions_confirmed(header: Uint8Array, txdata: TwoTuple_usizeTransactionZ[], height: number): void;
67                                 transaction_unconfirmed(txid: Uint8Array): void;
68                                 best_block_updated(header: Uint8Array, height: number): void;
69                                 get_relevant_txids(): Uint8Array[];
70                                 
71             }
72
73             class LDKConfirmHolder {
74                 held: Confirm;
75             }
76         public void transactions_confirmed(Uint8Array header, TwoTuple_usizeTransactionZ[] txdata, number height) {
77                 bindings.Confirm_transactions_confirmed(this.ptr, header, txdata != null ? Arrays.stream(txdata).map(txdata_conv_28 -> txdata_conv_28 != null ? txdata_conv_28.ptr : 0).toArray(number[]::new) : null, height);
78         }
79
80         public void transaction_unconfirmed(Uint8Array txid) {
81                 bindings.Confirm_transaction_unconfirmed(this.ptr, txid);
82         }
83
84         public void best_block_updated(Uint8Array header, number height) {
85                 bindings.Confirm_best_block_updated(this.ptr, header, height);
86         }
87
88         public Uint8Array[] get_relevant_txids() {
89                 Uint8Array[] ret = bindings.Confirm_get_relevant_txids(this.ptr);
90                 return ret;
91         }
92
93 }