X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=ts%2Fstructs%2FFeeEstimator.ts;h=2bcefda5558178a542afd627a7396b8054859f9f;hb=22f5f4208b1f3b5542292250f1612b944f5cd7fd;hp=27368449aa2ea9057ff0a5c87dd84f24c3a6adf5;hpb=822471992c6bf6f9985e531cc5940e4cc35e3e4c;p=ldk-java diff --git a/ts/structs/FeeEstimator.ts b/ts/structs/FeeEstimator.ts index 27368449..2bcefda5 100644 --- a/ts/structs/FeeEstimator.ts +++ b/ts/structs/FeeEstimator.ts @@ -1,36 +1,58 @@ + import CommonBase from './CommonBase'; import * as bindings from '../bindings' // TODO: figure out location -public class FeeEstimator extends CommonBase { - final bindings.LDKFeeEstimator bindings_instance; - FeeEstimator(Object _dummy, long ptr) { super(ptr); bindings_instance = null; } - private FeeEstimator(bindings.LDKFeeEstimator arg) { - super(bindings.LDKFeeEstimator_new(arg)); - this.ptrs_to.add(arg); - this.bindings_instance = arg; - } - @Override @SuppressWarnings("deprecation") - protected void finalize() throws Throwable { - if (ptr != 0) { bindings.FeeEstimator_free(ptr); } super.finalize(); - } - public static interface FeeEstimatorInterface { - int get_est_sat_per_1000_weight(LDKConfirmationTarget confirmation_target); - } - private static class LDKFeeEstimatorHolder { FeeEstimator held; } - public static FeeEstimator new_impl(FeeEstimatorInterface arg) { - final LDKFeeEstimatorHolder impl_holder = new LDKFeeEstimatorHolder(); - impl_holder.held = new FeeEstimator(new bindings.LDKFeeEstimator() { - @Override public int get_est_sat_per_1000_weight(LDKConfirmationTarget confirmation_target) { - int ret = arg.get_est_sat_per_1000_weight(confirmation_target); + + export class FeeEstimator extends CommonBase { + + bindings_instance?: bindings.LDKFeeEstimator; + + constructor(ptr?: number, arg?: bindings.LDKFeeEstimator) { + if (Number.isFinite(ptr)) { + super(ptr); + this.bindings_instance = null; + } else { + // TODO: private constructor instantiation + super(bindings.LDKFeeEstimator_new(arg)); + this.ptrs_to.push(arg); + + } + } + + protected finalize() { + if (this.ptr != 0) { + bindings.FeeEstimator_free(this.ptr); + } + super.finalize(); + } + + static new_impl(arg: FeeEstimatorInterface): FeeEstimator { + const impl_holder: LDKFeeEstimatorHolder = new LDKFeeEstimatorHolder(); + let structImplementation = { + // todo: in-line interface filling + get_est_sat_per_1000_weight (confirmation_target: LDKConfirmationTarget): number { + number ret = arg.get_est_sat_per_1000_weight(confirmation_target); return ret; - } - }); - return impl_holder.held; - } - public int get_est_sat_per_1000_weight(LDKConfirmationTarget confirmation_target) { - int ret = bindings.FeeEstimator_get_est_sat_per_1000_weight(this.ptr, confirmation_target); + }, + + + }; + impl_holder.held = new FeeEstimator (null, structImplementation); + } + } + + export interface FeeEstimatorInterface { + get_est_sat_per_1000_weight(confirmation_target: LDKConfirmationTarget): number; + + } + + class LDKFeeEstimatorHolder { + held: FeeEstimator; + } + public number get_est_sat_per_1000_weight(LDKConfirmationTarget confirmation_target) { + number ret = bindings.FeeEstimator_get_est_sat_per_1000_weight(this.ptr, confirmation_target); return ret; }