Skip to content

Commit bbf1ef5

Browse files
committed
[TS] Update auto-generated bindings with changes + upstream changes
1 parent 65e786e commit bbf1ef5

18 files changed

+1143
-357
lines changed

ts/bindings.c

Lines changed: 386 additions & 160 deletions
Large diffs are not rendered by default.

ts/bindings.c.body

Lines changed: 386 additions & 160 deletions
Large diffs are not rendered by default.

ts/bindings.mts

Lines changed: 168 additions & 30 deletions
Large diffs are not rendered by default.

ts/structs/CommitmentSigned.mts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,24 @@ export class CommitmentSigned extends CommonBase {
397397
bindings.CommitmentSigned_set_signature(this.ptr, bindings.encodeUint8Array(bindings.check_arr_len(val, 64)));
398398
}
399399

400+
/**
401+
* Signatures on the HTLC transactions
402+
*
403+
* Returns a copy of the field.
404+
*/
405+
public get_htlc_signatures(): Uint8Array[] {
406+
const ret: number = bindings.CommitmentSigned_get_htlc_signatures(this.ptr);
407+
const ret_conv_12_len: number = bindings.getArrayLength(ret);
408+
const ret_conv_12_arr: Uint8Array[] = new Array(ret_conv_12_len).fill(null);
409+
for (var m = 0; m < ret_conv_12_len; m++) {
410+
const ret_conv_12: number = bindings.getU32ArrayElem(ret, m);
411+
const ret_conv_12_conv: Uint8Array = bindings.decodeUint8Array(ret_conv_12);
412+
ret_conv_12_arr[m] = ret_conv_12_conv;
413+
}
414+
bindings.freeWasmMemory(ret)
415+
return ret_conv_12_arr;
416+
}
417+
400418
/**
401419
* Signatures on the HTLC transactions
402420
*/

ts/structs/CommonBase.mts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ export class CommonBase {
367367
protected constructor(ptr: number, free_fn: (ptr: number) => void) {
368368
this.ptr = ptr;
369369
if (Number.isFinite(ptr) && ptr != 0){
370-
finalizer.register(this, get_freeer(ptr, free_fn));
370+
finalizer.register(this, get_freeer(ptr, free_fn), this);
371371
}
372372
}
373373
// In Java, protected means "any subclass can access fields on any other subclass'"
@@ -381,7 +381,10 @@ export class CommonBase {
381381
}
382382
protected static set_null_skip_free(o: CommonBase) {
383383
o.ptr = 0;
384-
finalizer.unregister(o);
384+
// @ts-ignore TypeScript is wrong about the returnvalue of unregister here!
385+
const did_unregister: boolean = finalizer.unregister(o);
386+
if (!did_unregister)
387+
throw new Error("FinalizationRegistry unregister should always unregister unless you double-free'd");
385388
}
386389
}
387390

ts/structs/DelayedPaymentOutputDescriptor.mts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,17 @@ export class DelayedPaymentOutputDescriptor extends CommonBase {
416416
bindings.DelayedPaymentOutputDescriptor_set_to_self_delay(this.ptr, val);
417417
}
418418

419+
/**
420+
* The output which is referenced by the given outpoint
421+
*
422+
* Returns a copy of the field.
423+
*/
424+
public get_output(): TxOut {
425+
const ret: number = bindings.DelayedPaymentOutputDescriptor_get_output(this.ptr);
426+
const ret_conv: TxOut = new TxOut(null, ret);
427+
return ret_conv;
428+
}
429+
419430
/**
420431
* The output which is referenced by the given outpoint
421432
*/

ts/structs/HolderCommitmentTransaction.mts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,24 @@ export class HolderCommitmentTransaction extends CommonBase {
383383
bindings.HolderCommitmentTransaction_set_counterparty_sig(this.ptr, bindings.encodeUint8Array(bindings.check_arr_len(val, 64)));
384384
}
385385

386+
/**
387+
* All non-dust counterparty HTLC signatures, in the order they appear in the transaction
388+
*
389+
* Returns a copy of the field.
390+
*/
391+
public get_counterparty_htlc_sigs(): Uint8Array[] {
392+
const ret: number = bindings.HolderCommitmentTransaction_get_counterparty_htlc_sigs(this.ptr);
393+
const ret_conv_12_len: number = bindings.getArrayLength(ret);
394+
const ret_conv_12_arr: Uint8Array[] = new Array(ret_conv_12_len).fill(null);
395+
for (var m = 0; m < ret_conv_12_len; m++) {
396+
const ret_conv_12: number = bindings.getU32ArrayElem(ret, m);
397+
const ret_conv_12_conv: Uint8Array = bindings.decodeUint8Array(ret_conv_12);
398+
ret_conv_12_arr[m] = ret_conv_12_conv;
399+
}
400+
bindings.freeWasmMemory(ret)
401+
return ret_conv_12_arr;
402+
}
403+
386404
/**
387405
* All non-dust counterparty HTLC signatures, in the order they appear in the transaction
388406
*/

ts/structs/LockedChannelMonitor.mts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -355,8 +355,9 @@ import { DefaultRouter } from '../structs/DefaultRouter.mjs';
355355
import { CommonBase, UInt5, WitnessVersion, UnqualifiedError } from './CommonBase.mjs';
356356
import * as bindings from '../bindings.mjs'
357357

358-
/** XXX: DO NOT USE THIS - it remains locked until the GC runs (if that ever happens */
358+
359359
/**
360+
* This type represents a lock and MUST BE MANUALLY FREE'd!
360361
* A read-only reference to a current ChannelMonitor.
361362
*
362363
* Note that this holds a mutex in [`ChainMonitor`] and may block other events until it is
@@ -365,7 +366,12 @@ import * as bindings from '../bindings.mjs'
365366
export class LockedChannelMonitor extends CommonBase {
366367
/* @internal */
367368
public constructor(_dummy: object, ptr: number) {
368-
super(ptr, bindings.LockedChannelMonitor_free);
369+
super(ptr, () => { throw new Error("Locks must be manually freed with free()"); });
370+
}
371+
/** Releases this lock */
372+
public free() {
373+
bindings.LockedChannelMonitor_free(this.ptr);
374+
CommonBase.set_null_skip_free(this);
369375
}
370376

371377
}

ts/structs/NodeAnnouncementInfo.mts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,25 @@ export class NodeAnnouncementInfo extends CommonBase {
436436
bindings.NodeAnnouncementInfo_set_alias(this.ptr, val == null ? 0 : CommonBase.get_ptr_of(val) & ~1);
437437
}
438438

439+
/**
440+
* Internet-level addresses via which one can connect to the node
441+
*
442+
* Returns a copy of the field.
443+
*/
444+
public get_addresses(): NetAddress[] {
445+
const ret: number = bindings.NodeAnnouncementInfo_get_addresses(this.ptr);
446+
const ret_conv_12_len: number = bindings.getArrayLength(ret);
447+
const ret_conv_12_arr: NetAddress[] = new Array(ret_conv_12_len).fill(null);
448+
for (var m = 0; m < ret_conv_12_len; m++) {
449+
const ret_conv_12: number = bindings.getU32ArrayElem(ret, m);
450+
const ret_conv_12_hu_conv: NetAddress = NetAddress.constr_from_ptr(ret_conv_12);
451+
CommonBase.add_ref_from(ret_conv_12_hu_conv, this);
452+
ret_conv_12_arr[m] = ret_conv_12_hu_conv;
453+
}
454+
bindings.freeWasmMemory(ret)
455+
return ret_conv_12_arr;
456+
}
457+
439458
/**
440459
* Internet-level addresses via which one can connect to the node
441460
*/

ts/structs/NodeInfo.mts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,17 @@ export class NodeInfo extends CommonBase {
365365
super(ptr, bindings.NodeInfo_free);
366366
}
367367

368+
/**
369+
* All valid channels a node has announced
370+
*
371+
* Returns a copy of the field.
372+
*/
373+
public get_channels(): bigint[] {
374+
const ret: number = bindings.NodeInfo_get_channels(this.ptr);
375+
const ret_conv: bigint[] = bindings.decodeUint64Array(ret);
376+
return ret_conv;
377+
}
378+
368379
/**
369380
* All valid channels a node has announced
370381
*/

0 commit comments

Comments
 (0)