import * as bindings from '../bindings.mjs'
+/**
+ * A reference to a transaction output.
+ *
+ * Differs from bitcoin::blockdata::transaction::OutPoint as the index is a u16 instead of u32
+ * due to LN's restrictions on index values. Should reduce (possibly) unsafe conversions this way.
+ */
export class OutPoint extends CommonBase {
/* @internal */
public constructor(_dummy: object, ptr: number) {
super(ptr, bindings.OutPoint_free);
}
+ /**
+ * The referenced transaction's txid.
+ */
public get_txid(): Uint8Array {
const ret: number = bindings.OutPoint_get_txid(this.ptr);
const ret_conv: Uint8Array = bindings.decodeUint8Array(ret);
return ret_conv;
}
+ /**
+ * The referenced transaction's txid.
+ */
public set_txid(val: Uint8Array): void {
bindings.OutPoint_set_txid(this.ptr, bindings.encodeUint8Array(bindings.check_arr_len(val, 32)));
}
+ /**
+ * The index of the referenced output in its transaction's vout.
+ */
public get_index(): number {
const ret: number = bindings.OutPoint_get_index(this.ptr);
return ret;
}
+ /**
+ * The index of the referenced output in its transaction's vout.
+ */
public set_index(val: number): void {
bindings.OutPoint_set_index(this.ptr, val);
}
+ /**
+ * Constructs a new OutPoint given each field
+ */
public static constructor_new(txid_arg: Uint8Array, index_arg: number): OutPoint {
const ret: number = bindings.OutPoint_new(bindings.encodeUint8Array(bindings.check_arr_len(txid_arg, 32)), index_arg);
const ret_hu_conv: OutPoint = new OutPoint(null, ret);
return ret;
}
+ /**
+ * Creates a copy of the OutPoint
+ */
public clone(): OutPoint {
const ret: number = bindings.OutPoint_clone(this.ptr);
const ret_hu_conv: OutPoint = new OutPoint(null, ret);
return ret_hu_conv;
}
+ /**
+ * Checks if two OutPoints contain equal inner contents.
+ * This ignores pointers and is_owned flags and looks at the values in fields.
+ * Two objects with NULL inner values will be considered "equal" here.
+ */
public eq(b: OutPoint): boolean {
const ret: boolean = bindings.OutPoint_eq(this.ptr, b == null ? 0 : CommonBase.get_ptr_of(b) & ~1);
CommonBase.add_ref_from(this, b);
return ret;
}
+ /**
+ * Checks if two OutPoints contain equal inner contents.
+ */
public hash(): bigint {
const ret: bigint = bindings.OutPoint_hash(this.ptr);
return ret;
}
+ /**
+ * Convert an `OutPoint` to a lightning channel id.
+ */
public to_channel_id(): Uint8Array {
const ret: number = bindings.OutPoint_to_channel_id(this.ptr);
const ret_conv: Uint8Array = bindings.decodeUint8Array(ret);
return ret_conv;
}
+ /**
+ * Serialize the OutPoint object into a byte array which can be read by OutPoint_read
+ */
public write(): Uint8Array {
const ret: number = bindings.OutPoint_write(this.ptr);
const ret_conv: Uint8Array = bindings.decodeUint8Array(ret);
return ret_conv;
}
+ /**
+ * Read a OutPoint from a byte array, created by OutPoint_write
+ */
public static constructor_read(ser: Uint8Array): Result_OutPointDecodeErrorZ {
const ret: number = bindings.OutPoint_read(bindings.encodeUint8Array(ser));
const ret_hu_conv: Result_OutPointDecodeErrorZ = Result_OutPointDecodeErrorZ.constr_from_ptr(ret);