UNPKG

lightningdevkit

Version:
142 lines 5.55 kB
import { UnsignedChannelAnnouncement } from '../structs/UnsignedChannelAnnouncement.mjs'; import { Result_ChannelAnnouncementDecodeErrorZ } from '../structs/Result_ChannelAnnouncementDecodeErrorZ.mjs'; import { CommonBase } from './CommonBase.mjs'; import * as bindings from '../bindings.mjs'; /** * A [`channel_announcement`] message to be sent to or received from a peer. * * [`channel_announcement`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_announcement-message */ export class ChannelAnnouncement extends CommonBase { /* @internal */ constructor(_dummy, ptr) { super(ptr, bindings.ChannelAnnouncement_free); } /** * Authentication of the announcement by the first public node */ get_node_signature_1() { const ret = bindings.ChannelAnnouncement_get_node_signature_1(this.ptr); const ret_conv = bindings.decodeUint8Array(ret); return ret_conv; } /** * Authentication of the announcement by the first public node */ set_node_signature_1(val) { bindings.ChannelAnnouncement_set_node_signature_1(this.ptr, bindings.encodeUint8Array(val)); } /** * Authentication of the announcement by the second public node */ get_node_signature_2() { const ret = bindings.ChannelAnnouncement_get_node_signature_2(this.ptr); const ret_conv = bindings.decodeUint8Array(ret); return ret_conv; } /** * Authentication of the announcement by the second public node */ set_node_signature_2(val) { bindings.ChannelAnnouncement_set_node_signature_2(this.ptr, bindings.encodeUint8Array(val)); } /** * Proof of funding UTXO ownership by the first public node */ get_bitcoin_signature_1() { const ret = bindings.ChannelAnnouncement_get_bitcoin_signature_1(this.ptr); const ret_conv = bindings.decodeUint8Array(ret); return ret_conv; } /** * Proof of funding UTXO ownership by the first public node */ set_bitcoin_signature_1(val) { bindings.ChannelAnnouncement_set_bitcoin_signature_1(this.ptr, bindings.encodeUint8Array(val)); } /** * Proof of funding UTXO ownership by the second public node */ get_bitcoin_signature_2() { const ret = bindings.ChannelAnnouncement_get_bitcoin_signature_2(this.ptr); const ret_conv = bindings.decodeUint8Array(ret); return ret_conv; } /** * Proof of funding UTXO ownership by the second public node */ set_bitcoin_signature_2(val) { bindings.ChannelAnnouncement_set_bitcoin_signature_2(this.ptr, bindings.encodeUint8Array(val)); } /** * The actual announcement */ get_contents() { const ret = bindings.ChannelAnnouncement_get_contents(this.ptr); const ret_hu_conv = new UnsignedChannelAnnouncement(null, ret); CommonBase.add_ref_from(ret_hu_conv, this); return ret_hu_conv; } /** * The actual announcement */ set_contents(val) { bindings.ChannelAnnouncement_set_contents(this.ptr, CommonBase.get_ptr_of(val)); } /** * Constructs a new ChannelAnnouncement given each field */ static constructor_new(node_signature_1_arg, node_signature_2_arg, bitcoin_signature_1_arg, bitcoin_signature_2_arg, contents_arg) { const ret = bindings.ChannelAnnouncement_new(bindings.encodeUint8Array(node_signature_1_arg), bindings.encodeUint8Array(node_signature_2_arg), bindings.encodeUint8Array(bitcoin_signature_1_arg), bindings.encodeUint8Array(bitcoin_signature_2_arg), CommonBase.get_ptr_of(contents_arg)); const ret_hu_conv = new ChannelAnnouncement(null, ret); CommonBase.add_ref_from(ret_hu_conv, ret_hu_conv); return ret_hu_conv; } clone_ptr() { const ret = bindings.ChannelAnnouncement_clone_ptr(this.ptr); return ret; } /** * Creates a copy of the ChannelAnnouncement */ clone() { const ret = bindings.ChannelAnnouncement_clone(this.ptr); const ret_hu_conv = new ChannelAnnouncement(null, ret); CommonBase.add_ref_from(ret_hu_conv, this); return ret_hu_conv; } /** * Generates a non-cryptographic 64-bit hash of the ChannelAnnouncement. */ hash() { const ret = bindings.ChannelAnnouncement_hash(this.ptr); return ret; } /** * Checks if two ChannelAnnouncements 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.ChannelAnnouncement_eq(this.ptr, CommonBase.get_ptr_of(b)); CommonBase.add_ref_from(this, b); return ret; } /** * Serialize the ChannelAnnouncement object into a byte array which can be read by ChannelAnnouncement_read */ write() { const ret = bindings.ChannelAnnouncement_write(this.ptr); const ret_conv = bindings.decodeUint8Array(ret); return ret_conv; } /** * Read a ChannelAnnouncement from a byte array, created by ChannelAnnouncement_write */ static constructor_read(ser) { const ret = bindings.ChannelAnnouncement_read(bindings.encodeUint8Array(ser)); const ret_hu_conv = Result_ChannelAnnouncementDecodeErrorZ.constr_from_ptr(ret); return ret_hu_conv; } } //# sourceMappingURL=ChannelAnnouncement.mjs.map