3 import CommonBase from './CommonBase';
4 import * as bindings from '../bindings' // TODO: figure out location
8 export class Confirm extends CommonBase {
10 bindings_instance?: bindings.LDKConfirm;
12 constructor(ptr?: number, arg?: bindings.LDKConfirm) {
13 if (Number.isFinite(ptr)) {
15 this.bindings_instance = null;
17 // TODO: private constructor instantiation
18 super(bindings.LDKConfirm_new(arg));
19 this.ptrs_to.push(arg);
24 protected finalize() {
26 bindings.Confirm_free(this.ptr);
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;
43 arg.transactions_confirmed(header, txdata_conv_28_arr, height);
46 transaction_unconfirmed (txid: Uint8Array): void {
47 arg.transaction_unconfirmed(txid);
50 best_block_updated (header: Uint8Array, height: number): void {
51 arg.best_block_updated(header, height);
54 get_relevant_txids (): Uint8Array[] {
55 Uint8Array[] ret = arg.get_relevant_txids();
61 impl_holder.held = new Confirm (null, structImplementation);
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[];
73 class LDKConfirmHolder {
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);
80 public void transaction_unconfirmed(Uint8Array txid) {
81 bindings.Confirm_transaction_unconfirmed(this.ptr, txid);
84 public void best_block_updated(Uint8Array header, number height) {
85 bindings.Confirm_best_block_updated(this.ptr, header, height);
88 public Uint8Array[] get_relevant_txids() {
89 Uint8Array[] ret = bindings.Confirm_get_relevant_txids(this.ptr);