import CommonBase from './CommonBase.mjs';
import * as bindings from '../bindings.mjs'
-import * as InternalUtils from '../InternalUtils.mjs'
+/**
+ * An update_fulfill_htlc message to be sent or received from a peer
+ */
export class UpdateFulfillHTLC extends CommonBase {
/* @internal */
public constructor(_dummy: object, ptr: number) {
super(ptr, bindings.UpdateFulfillHTLC_free);
}
+ /**
+ * The channel ID
+ */
public get_channel_id(): Uint8Array {
- const ret: Uint8Array = bindings.UpdateFulfillHTLC_get_channel_id(this.ptr);
- return ret;
+ const ret: number = bindings.UpdateFulfillHTLC_get_channel_id(this.ptr);
+ const ret_conv: Uint8Array = bindings.decodeUint8Array(ret);
+ return ret_conv;
}
+ /**
+ * The channel ID
+ */
public set_channel_id(val: Uint8Array): void {
- bindings.UpdateFulfillHTLC_set_channel_id(this.ptr, InternalUtils.check_arr_len(val, 32));
+ bindings.UpdateFulfillHTLC_set_channel_id(this.ptr, bindings.encodeUint8Array(bindings.check_arr_len(val, 32)));
}
- public get_htlc_id(): number {
- const ret: number = bindings.UpdateFulfillHTLC_get_htlc_id(this.ptr);
+ /**
+ * The HTLC ID
+ */
+ public get_htlc_id(): bigint {
+ const ret: bigint = bindings.UpdateFulfillHTLC_get_htlc_id(this.ptr);
return ret;
}
- public set_htlc_id(val: number): void {
+ /**
+ * The HTLC ID
+ */
+ public set_htlc_id(val: bigint): void {
bindings.UpdateFulfillHTLC_set_htlc_id(this.ptr, val);
}
+ /**
+ * The pre-image of the payment hash, allowing HTLC redemption
+ */
public get_payment_preimage(): Uint8Array {
- const ret: Uint8Array = bindings.UpdateFulfillHTLC_get_payment_preimage(this.ptr);
- return ret;
+ const ret: number = bindings.UpdateFulfillHTLC_get_payment_preimage(this.ptr);
+ const ret_conv: Uint8Array = bindings.decodeUint8Array(ret);
+ return ret_conv;
}
+ /**
+ * The pre-image of the payment hash, allowing HTLC redemption
+ */
public set_payment_preimage(val: Uint8Array): void {
- bindings.UpdateFulfillHTLC_set_payment_preimage(this.ptr, InternalUtils.check_arr_len(val, 32));
+ bindings.UpdateFulfillHTLC_set_payment_preimage(this.ptr, bindings.encodeUint8Array(bindings.check_arr_len(val, 32)));
}
- public static constructor_new(channel_id_arg: Uint8Array, htlc_id_arg: number, payment_preimage_arg: Uint8Array): UpdateFulfillHTLC {
- const ret: number = bindings.UpdateFulfillHTLC_new(InternalUtils.check_arr_len(channel_id_arg, 32), htlc_id_arg, InternalUtils.check_arr_len(payment_preimage_arg, 32));
+ /**
+ * Constructs a new UpdateFulfillHTLC given each field
+ */
+ public static constructor_new(channel_id_arg: Uint8Array, htlc_id_arg: bigint, payment_preimage_arg: Uint8Array): UpdateFulfillHTLC {
+ const ret: number = bindings.UpdateFulfillHTLC_new(bindings.encodeUint8Array(bindings.check_arr_len(channel_id_arg, 32)), htlc_id_arg, bindings.encodeUint8Array(bindings.check_arr_len(payment_preimage_arg, 32)));
const ret_hu_conv: UpdateFulfillHTLC = new UpdateFulfillHTLC(null, ret);
CommonBase.add_ref_from(ret_hu_conv, ret_hu_conv);
return ret_hu_conv;
return ret;
}
+ /**
+ * Creates a copy of the UpdateFulfillHTLC
+ */
public clone(): UpdateFulfillHTLC {
const ret: number = bindings.UpdateFulfillHTLC_clone(this.ptr);
const ret_hu_conv: UpdateFulfillHTLC = new UpdateFulfillHTLC(null, ret);
return ret_hu_conv;
}
+ /**
+ * Serialize the UpdateFulfillHTLC object into a byte array which can be read by UpdateFulfillHTLC_read
+ */
public write(): Uint8Array {
- const ret: Uint8Array = bindings.UpdateFulfillHTLC_write(this.ptr);
- return ret;
+ const ret: number = bindings.UpdateFulfillHTLC_write(this.ptr);
+ const ret_conv: Uint8Array = bindings.decodeUint8Array(ret);
+ return ret_conv;
}
+ /**
+ * Read a UpdateFulfillHTLC from a byte array, created by UpdateFulfillHTLC_write
+ */
public static constructor_read(ser: Uint8Array): Result_UpdateFulfillHTLCDecodeErrorZ {
- const ret: number = bindings.UpdateFulfillHTLC_read(ser);
+ const ret: number = bindings.UpdateFulfillHTLC_read(bindings.encodeUint8Array(ser));
const ret_hu_conv: Result_UpdateFulfillHTLCDecodeErrorZ = Result_UpdateFulfillHTLCDecodeErrorZ.constr_from_ptr(ret);
return ret_hu_conv;
}