lightningdevkit
Version:
Lightning Development Kit
196 lines • 7.67 kB
JavaScript
import { NodeId } from '../structs/NodeId.mjs';
import { Result_UnsignedChannelAnnouncementDecodeErrorZ } from '../structs/Result_UnsignedChannelAnnouncementDecodeErrorZ.mjs';
import { ChannelFeatures } from '../structs/ChannelFeatures.mjs';
import { CommonBase } from './CommonBase.mjs';
import * as bindings from '../bindings.mjs';
/**
* The unsigned part of a [`channel_announcement`] message.
*
* [`channel_announcement`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_announcement-message
*/
export class UnsignedChannelAnnouncement extends CommonBase {
/* @internal */
constructor(_dummy, ptr) {
super(ptr, bindings.UnsignedChannelAnnouncement_free);
}
/**
* The advertised channel features
*/
get_features() {
const ret = bindings.UnsignedChannelAnnouncement_get_features(this.ptr);
const ret_hu_conv = new ChannelFeatures(null, ret);
CommonBase.add_ref_from(ret_hu_conv, this);
return ret_hu_conv;
}
/**
* The advertised channel features
*/
set_features(val) {
bindings.UnsignedChannelAnnouncement_set_features(this.ptr, CommonBase.get_ptr_of(val));
}
/**
* The genesis hash of the blockchain where the channel is to be opened
*/
get_chain_hash() {
const ret = bindings.UnsignedChannelAnnouncement_get_chain_hash(this.ptr);
const ret_conv = bindings.decodeUint8Array(ret);
return ret_conv;
}
/**
* The genesis hash of the blockchain where the channel is to be opened
*/
set_chain_hash(val) {
bindings.UnsignedChannelAnnouncement_set_chain_hash(this.ptr, bindings.encodeUint8Array(val));
}
/**
* The short channel ID
*/
get_short_channel_id() {
const ret = bindings.UnsignedChannelAnnouncement_get_short_channel_id(this.ptr);
return ret;
}
/**
* The short channel ID
*/
set_short_channel_id(val) {
bindings.UnsignedChannelAnnouncement_set_short_channel_id(this.ptr, val);
}
/**
* One of the two `node_id`s which are endpoints of this channel
*/
get_node_id_1() {
const ret = bindings.UnsignedChannelAnnouncement_get_node_id_1(this.ptr);
const ret_hu_conv = new NodeId(null, ret);
CommonBase.add_ref_from(ret_hu_conv, this);
return ret_hu_conv;
}
/**
* One of the two `node_id`s which are endpoints of this channel
*/
set_node_id_1(val) {
bindings.UnsignedChannelAnnouncement_set_node_id_1(this.ptr, CommonBase.get_ptr_of(val));
}
/**
* The other of the two `node_id`s which are endpoints of this channel
*/
get_node_id_2() {
const ret = bindings.UnsignedChannelAnnouncement_get_node_id_2(this.ptr);
const ret_hu_conv = new NodeId(null, ret);
CommonBase.add_ref_from(ret_hu_conv, this);
return ret_hu_conv;
}
/**
* The other of the two `node_id`s which are endpoints of this channel
*/
set_node_id_2(val) {
bindings.UnsignedChannelAnnouncement_set_node_id_2(this.ptr, CommonBase.get_ptr_of(val));
}
/**
* The funding key for the first node
*/
get_bitcoin_key_1() {
const ret = bindings.UnsignedChannelAnnouncement_get_bitcoin_key_1(this.ptr);
const ret_hu_conv = new NodeId(null, ret);
CommonBase.add_ref_from(ret_hu_conv, this);
return ret_hu_conv;
}
/**
* The funding key for the first node
*/
set_bitcoin_key_1(val) {
bindings.UnsignedChannelAnnouncement_set_bitcoin_key_1(this.ptr, CommonBase.get_ptr_of(val));
}
/**
* The funding key for the second node
*/
get_bitcoin_key_2() {
const ret = bindings.UnsignedChannelAnnouncement_get_bitcoin_key_2(this.ptr);
const ret_hu_conv = new NodeId(null, ret);
CommonBase.add_ref_from(ret_hu_conv, this);
return ret_hu_conv;
}
/**
* The funding key for the second node
*/
set_bitcoin_key_2(val) {
bindings.UnsignedChannelAnnouncement_set_bitcoin_key_2(this.ptr, CommonBase.get_ptr_of(val));
}
/**
* Excess data which was signed as a part of the message which we do not (yet) understand how
* to decode.
*
* This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol.
*
* Returns a copy of the field.
*/
get_excess_data() {
const ret = bindings.UnsignedChannelAnnouncement_get_excess_data(this.ptr);
const ret_conv = bindings.decodeUint8Array(ret);
return ret_conv;
}
/**
* Excess data which was signed as a part of the message which we do not (yet) understand how
* to decode.
*
* This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol.
*/
set_excess_data(val) {
bindings.UnsignedChannelAnnouncement_set_excess_data(this.ptr, bindings.encodeUint8Array(val));
}
/**
* Constructs a new UnsignedChannelAnnouncement given each field
*/
static constructor_new(features_arg, chain_hash_arg, short_channel_id_arg, node_id_1_arg, node_id_2_arg, bitcoin_key_1_arg, bitcoin_key_2_arg, excess_data_arg) {
const ret = bindings.UnsignedChannelAnnouncement_new(CommonBase.get_ptr_of(features_arg), bindings.encodeUint8Array(chain_hash_arg), short_channel_id_arg, CommonBase.get_ptr_of(node_id_1_arg), CommonBase.get_ptr_of(node_id_2_arg), CommonBase.get_ptr_of(bitcoin_key_1_arg), CommonBase.get_ptr_of(bitcoin_key_2_arg), bindings.encodeUint8Array(excess_data_arg));
const ret_hu_conv = new UnsignedChannelAnnouncement(null, ret);
CommonBase.add_ref_from(ret_hu_conv, ret_hu_conv);
return ret_hu_conv;
}
clone_ptr() {
const ret = bindings.UnsignedChannelAnnouncement_clone_ptr(this.ptr);
return ret;
}
/**
* Creates a copy of the UnsignedChannelAnnouncement
*/
clone() {
const ret = bindings.UnsignedChannelAnnouncement_clone(this.ptr);
const ret_hu_conv = new UnsignedChannelAnnouncement(null, ret);
CommonBase.add_ref_from(ret_hu_conv, this);
return ret_hu_conv;
}
/**
* Generates a non-cryptographic 64-bit hash of the UnsignedChannelAnnouncement.
*/
hash() {
const ret = bindings.UnsignedChannelAnnouncement_hash(this.ptr);
return ret;
}
/**
* Checks if two UnsignedChannelAnnouncements 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.UnsignedChannelAnnouncement_eq(this.ptr, CommonBase.get_ptr_of(b));
CommonBase.add_ref_from(this, b);
return ret;
}
/**
* Serialize the UnsignedChannelAnnouncement object into a byte array which can be read by UnsignedChannelAnnouncement_read
*/
write() {
const ret = bindings.UnsignedChannelAnnouncement_write(this.ptr);
const ret_conv = bindings.decodeUint8Array(ret);
return ret_conv;
}
/**
* Read a UnsignedChannelAnnouncement from a byte array, created by UnsignedChannelAnnouncement_write
*/
static constructor_read(ser) {
const ret = bindings.UnsignedChannelAnnouncement_read(bindings.encodeUint8Array(ser));
const ret_hu_conv = Result_UnsignedChannelAnnouncementDecodeErrorZ.constr_from_ptr(ret);
return ret_hu_conv;
}
}
//# sourceMappingURL=UnsignedChannelAnnouncement.mjs.map