X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=ts%2Fstructs%2FInit.mts;h=bda324db47d167915252849777b728c03d7c47d0;hb=ebef1f83fe4f70ba2f5c683a69f08e7ba32c8ad3;hp=11f72eafb0b03be0aa3cd4b8d38bb5930c985880;hpb=bf08029c1ad5244b59902eada723b634dcade62d;p=ldk-java diff --git a/ts/structs/Init.mts b/ts/structs/Init.mts index 11f72eaf..bda324db 100644 --- a/ts/structs/Init.mts +++ b/ts/structs/Init.mts @@ -279,15 +279,20 @@ import { MultiThreadedLockableScore } from '../structs/MultiThreadedLockableScor import CommonBase from './CommonBase.mjs'; import * as bindings from '../bindings.mjs' -import * as InternalUtils from '../InternalUtils.mjs' +/** + * An init message to be sent or received from a peer + */ export class Init extends CommonBase { /* @internal */ public constructor(_dummy: object, ptr: number) { super(ptr, bindings.Init_free); } + /** + * The relevant features which the sender supports + */ public get_features(): InitFeatures { const ret: number = bindings.Init_get_features(this.ptr); const ret_hu_conv: InitFeatures = new InitFeatures(null, ret); @@ -295,10 +300,16 @@ export class Init extends CommonBase { return ret_hu_conv; } + /** + * The relevant features which the sender supports + */ public set_features(val: InitFeatures): void { bindings.Init_set_features(this.ptr, val == null ? 0 : CommonBase.get_ptr_of(val) & ~1); } + /** + * Constructs a new Init given each field + */ public static constructor_new(features_arg: InitFeatures): Init { const ret: number = bindings.Init_new(features_arg == null ? 0 : CommonBase.get_ptr_of(features_arg) & ~1); const ret_hu_conv: Init = new Init(null, ret); @@ -311,6 +322,9 @@ export class Init extends CommonBase { return ret; } + /** + * Creates a copy of the Init + */ public clone(): Init { const ret: number = bindings.Init_clone(this.ptr); const ret_hu_conv: Init = new Init(null, ret); @@ -318,13 +332,20 @@ export class Init extends CommonBase { return ret_hu_conv; } + /** + * Serialize the Init object into a byte array which can be read by Init_read + */ public write(): Uint8Array { - const ret: Uint8Array = bindings.Init_write(this.ptr); - return ret; + const ret: number = bindings.Init_write(this.ptr); + const ret_conv: Uint8Array = bindings.decodeUint8Array(ret); + return ret_conv; } + /** + * Read a Init from a byte array, created by Init_write + */ public static constructor_read(ser: Uint8Array): Result_InitDecodeErrorZ { - const ret: number = bindings.Init_read(ser); + const ret: number = bindings.Init_read(bindings.encodeUint8Array(ser)); const ret_hu_conv: Result_InitDecodeErrorZ = Result_InitDecodeErrorZ.constr_from_ptr(ret); return ret_hu_conv; }