import CommonBase from './CommonBase.mjs';
import * as bindings from '../bindings.mjs'
-import * as InternalUtils from '../InternalUtils.mjs'
+/**
+ * Simple structure sent back by `chain::Watch` when an HTLC from a forward channel is detected on
+ * chain. Used to update the corresponding HTLC in the backward channel. Failing to pass the
+ * preimage claim backward will lead to loss of funds.
+ */
export class HTLCUpdate extends CommonBase {
/* @internal */
public constructor(_dummy: object, ptr: number) {
return ret;
}
+ /**
+ * Creates a copy of the HTLCUpdate
+ */
public clone(): HTLCUpdate {
const ret: number = bindings.HTLCUpdate_clone(this.ptr);
const ret_hu_conv: HTLCUpdate = new HTLCUpdate(null, ret);
return ret_hu_conv;
}
+ /**
+ * Serialize the HTLCUpdate object into a byte array which can be read by HTLCUpdate_read
+ */
public write(): Uint8Array {
- const ret: Uint8Array = bindings.HTLCUpdate_write(this.ptr);
- return ret;
+ const ret: number = bindings.HTLCUpdate_write(this.ptr);
+ const ret_conv: Uint8Array = bindings.decodeUint8Array(ret);
+ return ret_conv;
}
+ /**
+ * Read a HTLCUpdate from a byte array, created by HTLCUpdate_write
+ */
public static constructor_read(ser: Uint8Array): Result_HTLCUpdateDecodeErrorZ {
- const ret: number = bindings.HTLCUpdate_read(ser);
+ const ret: number = bindings.HTLCUpdate_read(bindings.encodeUint8Array(ser));
const ret_hu_conv: Result_HTLCUpdateDecodeErrorZ = Result_HTLCUpdateDecodeErrorZ.constr_from_ptr(ret);
return ret_hu_conv;
}