UNPKG

lightningdevkit

Version:
100 lines 3.61 kB
import { Result_BlindedHopDecodeErrorZ } from '../structs/Result_BlindedHopDecodeErrorZ.mjs'; import { CommonBase } from './CommonBase.mjs'; import * as bindings from '../bindings.mjs'; /** * An encrypted payload and node id corresponding to a hop in a payment or onion message path, to * be encoded in the sender's onion packet. These hops cannot be identified by outside observers * and thus can be used to hide the identity of the recipient. */ export class BlindedHop extends CommonBase { /* @internal */ constructor(_dummy, ptr) { super(ptr, bindings.BlindedHop_free); } /** * The blinded node id of this hop in a blinded path. */ get_blinded_node_id() { const ret = bindings.BlindedHop_get_blinded_node_id(this.ptr); const ret_conv = bindings.decodeUint8Array(ret); return ret_conv; } /** * The blinded node id of this hop in a blinded path. */ set_blinded_node_id(val) { bindings.BlindedHop_set_blinded_node_id(this.ptr, bindings.encodeUint8Array(val)); } /** * The encrypted payload intended for this hop in a blinded path. * * Returns a copy of the field. */ get_encrypted_payload() { const ret = bindings.BlindedHop_get_encrypted_payload(this.ptr); const ret_conv = bindings.decodeUint8Array(ret); return ret_conv; } /** * The encrypted payload intended for this hop in a blinded path. */ set_encrypted_payload(val) { bindings.BlindedHop_set_encrypted_payload(this.ptr, bindings.encodeUint8Array(val)); } /** * Constructs a new BlindedHop given each field */ static constructor_new(blinded_node_id_arg, encrypted_payload_arg) { const ret = bindings.BlindedHop_new(bindings.encodeUint8Array(blinded_node_id_arg), bindings.encodeUint8Array(encrypted_payload_arg)); const ret_hu_conv = new BlindedHop(null, ret); CommonBase.add_ref_from(ret_hu_conv, ret_hu_conv); return ret_hu_conv; } clone_ptr() { const ret = bindings.BlindedHop_clone_ptr(this.ptr); return ret; } /** * Creates a copy of the BlindedHop */ clone() { const ret = bindings.BlindedHop_clone(this.ptr); const ret_hu_conv = new BlindedHop(null, ret); CommonBase.add_ref_from(ret_hu_conv, this); return ret_hu_conv; } /** * Generates a non-cryptographic 64-bit hash of the BlindedHop. */ hash() { const ret = bindings.BlindedHop_hash(this.ptr); return ret; } /** * Checks if two BlindedHops 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. */ eq(b) { const ret = bindings.BlindedHop_eq(this.ptr, CommonBase.get_ptr_of(b)); CommonBase.add_ref_from(this, b); return ret; } /** * Serialize the BlindedHop object into a byte array which can be read by BlindedHop_read */ write() { const ret = bindings.BlindedHop_write(this.ptr); const ret_conv = bindings.decodeUint8Array(ret); return ret_conv; } /** * Read a BlindedHop from a byte array, created by BlindedHop_write */ static constructor_read(ser) { const ret = bindings.BlindedHop_read(bindings.encodeUint8Array(ser)); const ret_hu_conv = Result_BlindedHopDecodeErrorZ.constr_from_ptr(ret); return ret_hu_conv; } } //# sourceMappingURL=BlindedHop.mjs.map