lightningdevkit
Version:
Lightning Development Kit
125 lines • 5.11 kB
JavaScript
import { Result_BlindedForwardDecodeErrorZ } from '../structs/Result_BlindedForwardDecodeErrorZ.mjs';
import { CommonBase } from './CommonBase.mjs';
import * as bindings from '../bindings.mjs';
/**
* Information used to forward or fail this HTLC that is being forwarded within a blinded path.
*/
export class BlindedForward extends CommonBase {
/* @internal */
constructor(_dummy, ptr) {
super(ptr, bindings.BlindedForward_free);
}
/**
* The `blinding_point` that was set in the inbound [`msgs::UpdateAddHTLC`], or in the inbound
* onion payload if we're the introduction node. Useful for calculating the next hop's
* [`msgs::UpdateAddHTLC::blinding_point`].
*/
get_inbound_blinding_point() {
const ret = bindings.BlindedForward_get_inbound_blinding_point(this.ptr);
const ret_conv = bindings.decodeUint8Array(ret);
return ret_conv;
}
/**
* The `blinding_point` that was set in the inbound [`msgs::UpdateAddHTLC`], or in the inbound
* onion payload if we're the introduction node. Useful for calculating the next hop's
* [`msgs::UpdateAddHTLC::blinding_point`].
*/
set_inbound_blinding_point(val) {
bindings.BlindedForward_set_inbound_blinding_point(this.ptr, bindings.encodeUint8Array(val));
}
/**
* If needed, this determines how this HTLC should be failed backwards, based on whether we are
* the introduction node.
*/
get_failure() {
const ret = bindings.BlindedForward_get_failure(this.ptr);
return ret;
}
/**
* If needed, this determines how this HTLC should be failed backwards, based on whether we are
* the introduction node.
*/
set_failure(val) {
bindings.BlindedForward_set_failure(this.ptr, val);
}
/**
* Overrides the next hop's [`msgs::UpdateAddHTLC::blinding_point`]. Set if this HTLC is being
* forwarded within a [`BlindedPaymentPath`] that was concatenated to another blinded path that
* starts at the next hop.
*
* Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
*/
get_next_blinding_override() {
const ret = bindings.BlindedForward_get_next_blinding_override(this.ptr);
const ret_conv = bindings.decodeUint8Array(ret);
return ret_conv;
}
/**
* Overrides the next hop's [`msgs::UpdateAddHTLC::blinding_point`]. Set if this HTLC is being
* forwarded within a [`BlindedPaymentPath`] that was concatenated to another blinded path that
* starts at the next hop.
*
* Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
*/
set_next_blinding_override(val) {
bindings.BlindedForward_set_next_blinding_override(this.ptr, bindings.encodeUint8Array(val));
}
/**
* Constructs a new BlindedForward given each field
*
* Note that next_blinding_override_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
*/
static constructor_new(inbound_blinding_point_arg, failure_arg, next_blinding_override_arg) {
const ret = bindings.BlindedForward_new(bindings.encodeUint8Array(inbound_blinding_point_arg), failure_arg, bindings.encodeUint8Array(next_blinding_override_arg));
const ret_hu_conv = new BlindedForward(null, ret);
CommonBase.add_ref_from(ret_hu_conv, ret_hu_conv);
return ret_hu_conv;
}
clone_ptr() {
const ret = bindings.BlindedForward_clone_ptr(this.ptr);
return ret;
}
/**
* Creates a copy of the BlindedForward
*/
clone() {
const ret = bindings.BlindedForward_clone(this.ptr);
const ret_hu_conv = new BlindedForward(null, ret);
CommonBase.add_ref_from(ret_hu_conv, this);
return ret_hu_conv;
}
/**
* Generates a non-cryptographic 64-bit hash of the BlindedForward.
*/
hash() {
const ret = bindings.BlindedForward_hash(this.ptr);
return ret;
}
/**
* Checks if two BlindedForwards 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.BlindedForward_eq(this.ptr, CommonBase.get_ptr_of(b));
CommonBase.add_ref_from(this, b);
return ret;
}
/**
* Serialize the BlindedForward object into a byte array which can be read by BlindedForward_read
*/
write() {
const ret = bindings.BlindedForward_write(this.ptr);
const ret_conv = bindings.decodeUint8Array(ret);
return ret_conv;
}
/**
* Read a BlindedForward from a byte array, created by BlindedForward_write
*/
static constructor_read(ser) {
const ret = bindings.BlindedForward_read(bindings.encodeUint8Array(ser));
const ret_hu_conv = Result_BlindedForwardDecodeErrorZ.constr_from_ptr(ret);
return ret_hu_conv;
}
}
//# sourceMappingURL=BlindedForward.mjs.map