lightningdevkit
Version:
Lightning Development Kit
199 lines • 7.37 kB
JavaScript
import { Option_u64Z } from '../structs/Option_u64Z.mjs';
import { ChannelId } from '../structs/ChannelId.mjs';
import { OnionPacket } from '../structs/OnionPacket.mjs';
import { Result_UpdateAddHTLCDecodeErrorZ } from '../structs/Result_UpdateAddHTLCDecodeErrorZ.mjs';
import { CommonBase } from './CommonBase.mjs';
import * as bindings from '../bindings.mjs';
/**
* An [`update_add_htlc`] message to be sent to or received from a peer.
*
* [`update_add_htlc`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#adding-an-htlc-update_add_htlc
*/
export class UpdateAddHTLC extends CommonBase {
/* @internal */
constructor(_dummy, ptr) {
super(ptr, bindings.UpdateAddHTLC_free);
}
/**
* The channel ID
*/
get_channel_id() {
const ret = bindings.UpdateAddHTLC_get_channel_id(this.ptr);
const ret_hu_conv = new ChannelId(null, ret);
CommonBase.add_ref_from(ret_hu_conv, this);
return ret_hu_conv;
}
/**
* The channel ID
*/
set_channel_id(val) {
bindings.UpdateAddHTLC_set_channel_id(this.ptr, CommonBase.get_ptr_of(val));
}
/**
* The HTLC ID
*/
get_htlc_id() {
const ret = bindings.UpdateAddHTLC_get_htlc_id(this.ptr);
return ret;
}
/**
* The HTLC ID
*/
set_htlc_id(val) {
bindings.UpdateAddHTLC_set_htlc_id(this.ptr, val);
}
/**
* The HTLC value in milli-satoshi
*/
get_amount_msat() {
const ret = bindings.UpdateAddHTLC_get_amount_msat(this.ptr);
return ret;
}
/**
* The HTLC value in milli-satoshi
*/
set_amount_msat(val) {
bindings.UpdateAddHTLC_set_amount_msat(this.ptr, val);
}
/**
* The payment hash, the pre-image of which controls HTLC redemption
*/
get_payment_hash() {
const ret = bindings.UpdateAddHTLC_get_payment_hash(this.ptr);
const ret_conv = bindings.decodeUint8Array(ret);
return ret_conv;
}
/**
* The payment hash, the pre-image of which controls HTLC redemption
*/
set_payment_hash(val) {
bindings.UpdateAddHTLC_set_payment_hash(this.ptr, bindings.encodeUint8Array(val));
}
/**
* The expiry height of the HTLC
*/
get_cltv_expiry() {
const ret = bindings.UpdateAddHTLC_get_cltv_expiry(this.ptr);
return ret;
}
/**
* The expiry height of the HTLC
*/
set_cltv_expiry(val) {
bindings.UpdateAddHTLC_set_cltv_expiry(this.ptr, val);
}
/**
* The extra fee skimmed by the sender of this message. See
* [`ChannelConfig::accept_underpaying_htlcs`].
*
* [`ChannelConfig::accept_underpaying_htlcs`]: crate::util::config::ChannelConfig::accept_underpaying_htlcs
*/
get_skimmed_fee_msat() {
const ret = bindings.UpdateAddHTLC_get_skimmed_fee_msat(this.ptr);
const ret_hu_conv = Option_u64Z.constr_from_ptr(ret);
CommonBase.add_ref_from(ret_hu_conv, this);
return ret_hu_conv;
}
/**
* The extra fee skimmed by the sender of this message. See
* [`ChannelConfig::accept_underpaying_htlcs`].
*
* [`ChannelConfig::accept_underpaying_htlcs`]: crate::util::config::ChannelConfig::accept_underpaying_htlcs
*/
set_skimmed_fee_msat(val) {
bindings.UpdateAddHTLC_set_skimmed_fee_msat(this.ptr, CommonBase.get_ptr_of(val));
}
/**
* The onion routing packet with encrypted data for the next hop.
*/
get_onion_routing_packet() {
const ret = bindings.UpdateAddHTLC_get_onion_routing_packet(this.ptr);
const ret_hu_conv = new OnionPacket(null, ret);
CommonBase.add_ref_from(ret_hu_conv, this);
return ret_hu_conv;
}
/**
* The onion routing packet with encrypted data for the next hop.
*/
set_onion_routing_packet(val) {
bindings.UpdateAddHTLC_set_onion_routing_packet(this.ptr, CommonBase.get_ptr_of(val));
}
/**
* Provided if we are relaying or receiving a payment within a blinded path, to decrypt the onion
* routing packet and the recipient-provided encrypted payload within.
*
* Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
*/
get_blinding_point() {
const ret = bindings.UpdateAddHTLC_get_blinding_point(this.ptr);
const ret_conv = bindings.decodeUint8Array(ret);
return ret_conv;
}
/**
* Provided if we are relaying or receiving a payment within a blinded path, to decrypt the onion
* routing packet and the recipient-provided encrypted payload within.
*
* Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
*/
set_blinding_point(val) {
bindings.UpdateAddHTLC_set_blinding_point(this.ptr, bindings.encodeUint8Array(val));
}
/**
* Constructs a new UpdateAddHTLC given each field
*
* Note that blinding_point_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
*/
static constructor_new(channel_id_arg, htlc_id_arg, amount_msat_arg, payment_hash_arg, cltv_expiry_arg, skimmed_fee_msat_arg, onion_routing_packet_arg, blinding_point_arg) {
const ret = bindings.UpdateAddHTLC_new(CommonBase.get_ptr_of(channel_id_arg), htlc_id_arg, amount_msat_arg, bindings.encodeUint8Array(payment_hash_arg), cltv_expiry_arg, CommonBase.get_ptr_of(skimmed_fee_msat_arg), CommonBase.get_ptr_of(onion_routing_packet_arg), bindings.encodeUint8Array(blinding_point_arg));
const ret_hu_conv = new UpdateAddHTLC(null, ret);
CommonBase.add_ref_from(ret_hu_conv, ret_hu_conv);
return ret_hu_conv;
}
clone_ptr() {
const ret = bindings.UpdateAddHTLC_clone_ptr(this.ptr);
return ret;
}
/**
* Creates a copy of the UpdateAddHTLC
*/
clone() {
const ret = bindings.UpdateAddHTLC_clone(this.ptr);
const ret_hu_conv = new UpdateAddHTLC(null, ret);
CommonBase.add_ref_from(ret_hu_conv, this);
return ret_hu_conv;
}
/**
* Generates a non-cryptographic 64-bit hash of the UpdateAddHTLC.
*/
hash() {
const ret = bindings.UpdateAddHTLC_hash(this.ptr);
return ret;
}
/**
* Checks if two UpdateAddHTLCs 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.UpdateAddHTLC_eq(this.ptr, CommonBase.get_ptr_of(b));
CommonBase.add_ref_from(this, b);
return ret;
}
/**
* Serialize the UpdateAddHTLC object into a byte array which can be read by UpdateAddHTLC_read
*/
write() {
const ret = bindings.UpdateAddHTLC_write(this.ptr);
const ret_conv = bindings.decodeUint8Array(ret);
return ret_conv;
}
/**
* Read a UpdateAddHTLC from a byte array, created by UpdateAddHTLC_write
*/
static constructor_read(ser) {
const ret = bindings.UpdateAddHTLC_read(bindings.encodeUint8Array(ser));
const ret_hu_conv = Result_UpdateAddHTLCDecodeErrorZ.constr_from_ptr(ret);
return ret_hu_conv;
}
}
//# sourceMappingURL=UpdateAddHTLC.mjs.map