lightningdevkit
Version:
Lightning Development Kit
129 lines • 4.71 kB
JavaScript
import { ChannelId } from '../structs/ChannelId.mjs';
import { Result_FundingCreatedDecodeErrorZ } from '../structs/Result_FundingCreatedDecodeErrorZ.mjs';
import { CommonBase } from './CommonBase.mjs';
import * as bindings from '../bindings.mjs';
/**
* A [`funding_created`] message to be sent to or received from a peer.
*
* Used in V1 channel establishment
*
* [`funding_created`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-funding_created-message
*/
export class FundingCreated extends CommonBase {
/* @internal */
constructor(_dummy, ptr) {
super(ptr, bindings.FundingCreated_free);
}
/**
* A temporary channel ID, until the funding is established
*/
get_temporary_channel_id() {
const ret = bindings.FundingCreated_get_temporary_channel_id(this.ptr);
const ret_hu_conv = new ChannelId(null, ret);
CommonBase.add_ref_from(ret_hu_conv, this);
return ret_hu_conv;
}
/**
* A temporary channel ID, until the funding is established
*/
set_temporary_channel_id(val) {
bindings.FundingCreated_set_temporary_channel_id(this.ptr, CommonBase.get_ptr_of(val));
}
/**
* The funding transaction ID
*/
get_funding_txid() {
const ret = bindings.FundingCreated_get_funding_txid(this.ptr);
const ret_conv = bindings.decodeUint8Array(ret);
return ret_conv;
}
/**
* The funding transaction ID
*/
set_funding_txid(val) {
bindings.FundingCreated_set_funding_txid(this.ptr, bindings.encodeUint8Array(val));
}
/**
* The specific output index funding this channel
*/
get_funding_output_index() {
const ret = bindings.FundingCreated_get_funding_output_index(this.ptr);
return ret;
}
/**
* The specific output index funding this channel
*/
set_funding_output_index(val) {
bindings.FundingCreated_set_funding_output_index(this.ptr, val);
}
/**
* The signature of the channel initiator (funder) on the initial commitment transaction
*/
get_signature() {
const ret = bindings.FundingCreated_get_signature(this.ptr);
const ret_conv = bindings.decodeUint8Array(ret);
return ret_conv;
}
/**
* The signature of the channel initiator (funder) on the initial commitment transaction
*/
set_signature(val) {
bindings.FundingCreated_set_signature(this.ptr, bindings.encodeUint8Array(val));
}
/**
* Constructs a new FundingCreated given each field
*/
static constructor_new(temporary_channel_id_arg, funding_txid_arg, funding_output_index_arg, signature_arg) {
const ret = bindings.FundingCreated_new(CommonBase.get_ptr_of(temporary_channel_id_arg), bindings.encodeUint8Array(funding_txid_arg), funding_output_index_arg, bindings.encodeUint8Array(signature_arg));
const ret_hu_conv = new FundingCreated(null, ret);
CommonBase.add_ref_from(ret_hu_conv, ret_hu_conv);
return ret_hu_conv;
}
clone_ptr() {
const ret = bindings.FundingCreated_clone_ptr(this.ptr);
return ret;
}
/**
* Creates a copy of the FundingCreated
*/
clone() {
const ret = bindings.FundingCreated_clone(this.ptr);
const ret_hu_conv = new FundingCreated(null, ret);
CommonBase.add_ref_from(ret_hu_conv, this);
return ret_hu_conv;
}
/**
* Generates a non-cryptographic 64-bit hash of the FundingCreated.
*/
hash() {
const ret = bindings.FundingCreated_hash(this.ptr);
return ret;
}
/**
* Checks if two FundingCreateds 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.FundingCreated_eq(this.ptr, CommonBase.get_ptr_of(b));
CommonBase.add_ref_from(this, b);
return ret;
}
/**
* Serialize the FundingCreated object into a byte array which can be read by FundingCreated_read
*/
write() {
const ret = bindings.FundingCreated_write(this.ptr);
const ret_conv = bindings.decodeUint8Array(ret);
return ret_conv;
}
/**
* Read a FundingCreated from a byte array, created by FundingCreated_write
*/
static constructor_read(ser) {
const ret = bindings.FundingCreated_read(bindings.encodeUint8Array(ser));
const ret_hu_conv = Result_FundingCreatedDecodeErrorZ.constr_from_ptr(ret);
return ret_hu_conv;
}
}
//# sourceMappingURL=FundingCreated.mjs.map