lightningdevkit
Version:
Lightning Development Kit
181 lines • 7.08 kB
JavaScript
import { Option_u64Z } from '../structs/Option_u64Z.mjs';
import { Option_ThirtyTwoBytesZ } from '../structs/Option_ThirtyTwoBytesZ.mjs';
import { Option_CVec_u8ZZ } from '../structs/Option_CVec_u8ZZ.mjs';
import { PayeePubKey } from '../structs/PayeePubKey.mjs';
import { PrivateRoute } from '../structs/PrivateRoute.mjs';
import { Description } from '../structs/Description.mjs';
import { Bolt11InvoiceFeatures } from '../structs/Bolt11InvoiceFeatures.mjs';
import { Sha256 } from '../structs/Sha256.mjs';
import { RawDataPart } from '../structs/RawDataPart.mjs';
import { ExpiryTime } from '../structs/ExpiryTime.mjs';
import { MinFinalCltvExpiryDelta } from '../structs/MinFinalCltvExpiryDelta.mjs';
import { CommonBase } from './CommonBase.mjs';
import * as bindings from '../bindings.mjs';
/**
* Represents an syntactically correct [`Bolt11Invoice`] for a payment on the lightning network,
* but without the signature information.
* Decoding and encoding should not lead to information loss but may lead to different hashes.
*
* For methods without docs see the corresponding methods in [`Bolt11Invoice`].
*/
export class RawBolt11Invoice extends CommonBase {
/* @internal */
constructor(_dummy, ptr) {
super(ptr, bindings.RawBolt11Invoice_free);
}
/**
* data part
*/
get_data() {
const ret = bindings.RawBolt11Invoice_get_data(this.ptr);
const ret_hu_conv = new RawDataPart(null, ret);
CommonBase.add_ref_from(ret_hu_conv, this);
return ret_hu_conv;
}
/**
* data part
*/
set_data(val) {
bindings.RawBolt11Invoice_set_data(this.ptr, CommonBase.get_ptr_of(val));
}
/**
* Checks if two RawBolt11Invoices 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.RawBolt11Invoice_eq(this.ptr, CommonBase.get_ptr_of(b));
CommonBase.add_ref_from(this, b);
return ret;
}
clone_ptr() {
const ret = bindings.RawBolt11Invoice_clone_ptr(this.ptr);
return ret;
}
/**
* Creates a copy of the RawBolt11Invoice
*/
clone() {
const ret = bindings.RawBolt11Invoice_clone(this.ptr);
const ret_hu_conv = new RawBolt11Invoice(null, ret);
CommonBase.add_ref_from(ret_hu_conv, this);
return ret_hu_conv;
}
/**
* Generates a non-cryptographic 64-bit hash of the RawBolt11Invoice.
*/
hash() {
const ret = bindings.RawBolt11Invoice_hash(this.ptr);
return ret;
}
/**
* Calculate the hash of the encoded `RawBolt11Invoice` which should be signed.
*/
signable_hash() {
const ret = bindings.RawBolt11Invoice_signable_hash(this.ptr);
const ret_conv = bindings.decodeUint8Array(ret);
return ret_conv;
}
/**
* Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
*/
payment_hash() {
const ret = bindings.RawBolt11Invoice_payment_hash(this.ptr);
const ret_hu_conv = new Sha256(null, ret);
CommonBase.add_ref_from(ret_hu_conv, this);
return ret_hu_conv;
}
/**
* Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
*/
description() {
const ret = bindings.RawBolt11Invoice_description(this.ptr);
const ret_hu_conv = new Description(null, ret);
CommonBase.add_ref_from(ret_hu_conv, this);
return ret_hu_conv;
}
/**
* Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
*/
payee_pub_key() {
const ret = bindings.RawBolt11Invoice_payee_pub_key(this.ptr);
const ret_hu_conv = new PayeePubKey(null, ret);
CommonBase.add_ref_from(ret_hu_conv, this);
return ret_hu_conv;
}
/**
* Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
*/
description_hash() {
const ret = bindings.RawBolt11Invoice_description_hash(this.ptr);
const ret_hu_conv = new Sha256(null, ret);
CommonBase.add_ref_from(ret_hu_conv, this);
return ret_hu_conv;
}
/**
* Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
*/
expiry_time() {
const ret = bindings.RawBolt11Invoice_expiry_time(this.ptr);
const ret_hu_conv = new ExpiryTime(null, ret);
CommonBase.add_ref_from(ret_hu_conv, this);
return ret_hu_conv;
}
/**
* Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
*/
min_final_cltv_expiry_delta() {
const ret = bindings.RawBolt11Invoice_min_final_cltv_expiry_delta(this.ptr);
const ret_hu_conv = new MinFinalCltvExpiryDelta(null, ret);
CommonBase.add_ref_from(ret_hu_conv, this);
return ret_hu_conv;
}
payment_secret() {
const ret = bindings.RawBolt11Invoice_payment_secret(this.ptr);
const ret_hu_conv = Option_ThirtyTwoBytesZ.constr_from_ptr(ret);
CommonBase.add_ref_from(ret_hu_conv, this);
return ret_hu_conv;
}
payment_metadata() {
const ret = bindings.RawBolt11Invoice_payment_metadata(this.ptr);
const ret_hu_conv = Option_CVec_u8ZZ.constr_from_ptr(ret);
CommonBase.add_ref_from(ret_hu_conv, this);
return ret_hu_conv;
}
/**
* Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
*/
features() {
const ret = bindings.RawBolt11Invoice_features(this.ptr);
const ret_hu_conv = new Bolt11InvoiceFeatures(null, ret);
CommonBase.add_ref_from(ret_hu_conv, this);
return ret_hu_conv;
}
private_routes() {
const ret = bindings.RawBolt11Invoice_private_routes(this.ptr);
const ret_conv_14_len = bindings.getArrayLength(ret);
const ret_conv_14_arr = new Array(ret_conv_14_len).fill(null);
for (var o = 0; o < ret_conv_14_len; o++) {
const ret_conv_14 = bindings.getU64ArrayElem(ret, o);
const ret_conv_14_hu_conv = new PrivateRoute(null, ret_conv_14);
CommonBase.add_ref_from(ret_conv_14_hu_conv, this);
ret_conv_14_arr[o] = ret_conv_14_hu_conv;
}
bindings.freeWasmMemory(ret);
return ret_conv_14_arr;
}
/**
* Returns `None` if no amount is set or on overflow.
*/
amount_pico_btc() {
const ret = bindings.RawBolt11Invoice_amount_pico_btc(this.ptr);
const ret_hu_conv = Option_u64Z.constr_from_ptr(ret);
CommonBase.add_ref_from(ret_hu_conv, this);
return ret_hu_conv;
}
currency() {
const ret = bindings.RawBolt11Invoice_currency(this.ptr);
return ret;
}
}
//# sourceMappingURL=RawBolt11Invoice.mjs.map