lightningdevkit
Version:
Lightning Development Kit
75 lines • 2.81 kB
JavaScript
import { Result_TxOutUtxoLookupErrorZ } from '../structs/Result_TxOutUtxoLookupErrorZ.mjs';
import { UtxoFuture } from '../structs/UtxoFuture.mjs';
import { CommonBase } from './CommonBase.mjs';
import * as bindings from '../bindings.mjs';
/**
* The result of a [`UtxoLookup::get_utxo`] call. A call may resolve either synchronously,
* returning the `Sync` variant, or asynchronously, returning an [`UtxoFuture`] in the `Async`
* variant.
*/
export class UtxoResult extends CommonBase {
constructor(_dummy, ptr) { super(ptr, bindings.UtxoResult_free); }
/* @internal */
static constr_from_ptr(ptr) {
const raw_ty = bindings.LDKUtxoResult_ty_from_ptr(ptr);
switch (raw_ty) {
case 0: return new UtxoResult_Sync(ptr);
case 1: return new UtxoResult_Async(ptr);
default:
throw new Error('oops, this should be unreachable'); // Unreachable without extending the (internal) bindings interface
}
}
clone_ptr() {
const ret = bindings.UtxoResult_clone_ptr(this.ptr);
return ret;
}
/**
* Creates a copy of the UtxoResult
*/
clone() {
const ret = bindings.UtxoResult_clone(this.ptr);
const ret_hu_conv = UtxoResult.constr_from_ptr(ret);
CommonBase.add_ref_from(ret_hu_conv, this);
return ret_hu_conv;
}
/**
* Utility method to constructs a new Sync-variant UtxoResult
*/
static constructor_sync(a) {
const ret = bindings.UtxoResult_sync(CommonBase.get_ptr_of(a));
const ret_hu_conv = UtxoResult.constr_from_ptr(ret);
CommonBase.add_ref_from(ret_hu_conv, ret_hu_conv);
return ret_hu_conv;
}
/**
* Utility method to constructs a new Async-variant UtxoResult
*/
static constructor_async(a) {
const ret = bindings.UtxoResult_async(CommonBase.get_ptr_of(a));
const ret_hu_conv = UtxoResult.constr_from_ptr(ret);
CommonBase.add_ref_from(ret_hu_conv, ret_hu_conv);
return ret_hu_conv;
}
}
/** A UtxoResult of type Sync */
export class UtxoResult_Sync extends UtxoResult {
/* @internal */
constructor(ptr) {
super(null, ptr);
const sync = bindings.LDKUtxoResult_Sync_get_sync(ptr);
const sync_hu_conv = Result_TxOutUtxoLookupErrorZ.constr_from_ptr(sync);
this.sync = sync_hu_conv;
}
}
/** A UtxoResult of type Async */
export class UtxoResult_Async extends UtxoResult {
/* @internal */
constructor(ptr) {
super(null, ptr);
const async = bindings.LDKUtxoResult_Async_get_async(ptr);
const async_hu_conv = new UtxoFuture(null, async);
CommonBase.add_ref_from(async_hu_conv, this);
this.async = async_hu_conv;
}
}
//# sourceMappingURL=UtxoResult.mjs.map