lightningdevkit
Version:
Lightning Development Kit
111 lines • 4.61 kB
JavaScript
import { PaymentContext } from '../structs/PaymentContext.mjs';
import { ReceiveTlvs } from '../structs/ReceiveTlvs.mjs';
import { PaymentConstraints } from '../structs/PaymentConstraints.mjs';
import { Verification } from '../structs/Verification.mjs';
import { CommonBase } from './CommonBase.mjs';
import * as bindings from '../bindings.mjs';
/**
* An unauthenticated [`ReceiveTlvs`].
*/
export class UnauthenticatedReceiveTlvs extends CommonBase {
/* @internal */
constructor(_dummy, ptr) {
super(ptr, bindings.UnauthenticatedReceiveTlvs_free);
}
/**
* Constructs a new Verification which calls the relevant methods on this_arg.
* This copies the `inner` pointer in this_arg and thus the returned Verification must be freed before this_arg is
*/
as_Verification() {
const ret = bindings.UnauthenticatedReceiveTlvs_as_Verification(this.ptr);
const ret_hu_conv = new Verification(null, ret);
CommonBase.add_ref_from(ret_hu_conv, this);
return ret_hu_conv;
}
/**
* Used to authenticate the sender of a payment to the receiver and tie MPP HTLCs together.
*/
get_payment_secret() {
const ret = bindings.UnauthenticatedReceiveTlvs_get_payment_secret(this.ptr);
const ret_conv = bindings.decodeUint8Array(ret);
return ret_conv;
}
/**
* Used to authenticate the sender of a payment to the receiver and tie MPP HTLCs together.
*/
set_payment_secret(val) {
bindings.UnauthenticatedReceiveTlvs_set_payment_secret(this.ptr, bindings.encodeUint8Array(val));
}
/**
* Constraints for the receiver of this payment.
*/
get_payment_constraints() {
const ret = bindings.UnauthenticatedReceiveTlvs_get_payment_constraints(this.ptr);
const ret_hu_conv = new PaymentConstraints(null, ret);
CommonBase.add_ref_from(ret_hu_conv, this);
return ret_hu_conv;
}
/**
* Constraints for the receiver of this payment.
*/
set_payment_constraints(val) {
bindings.UnauthenticatedReceiveTlvs_set_payment_constraints(this.ptr, CommonBase.get_ptr_of(val));
}
/**
* Context for the receiver of this payment.
*/
get_payment_context() {
const ret = bindings.UnauthenticatedReceiveTlvs_get_payment_context(this.ptr);
const ret_hu_conv = PaymentContext.constr_from_ptr(ret);
CommonBase.add_ref_from(ret_hu_conv, this);
return ret_hu_conv;
}
/**
* Context for the receiver of this payment.
*/
set_payment_context(val) {
bindings.UnauthenticatedReceiveTlvs_set_payment_context(this.ptr, CommonBase.get_ptr_of(val));
}
/**
* Constructs a new UnauthenticatedReceiveTlvs given each field
*/
static constructor_new(payment_secret_arg, payment_constraints_arg, payment_context_arg) {
const ret = bindings.UnauthenticatedReceiveTlvs_new(bindings.encodeUint8Array(payment_secret_arg), CommonBase.get_ptr_of(payment_constraints_arg), CommonBase.get_ptr_of(payment_context_arg));
const ret_hu_conv = new UnauthenticatedReceiveTlvs(null, ret);
CommonBase.add_ref_from(ret_hu_conv, ret_hu_conv);
return ret_hu_conv;
}
clone_ptr() {
const ret = bindings.UnauthenticatedReceiveTlvs_clone_ptr(this.ptr);
return ret;
}
/**
* Creates a copy of the UnauthenticatedReceiveTlvs
*/
clone() {
const ret = bindings.UnauthenticatedReceiveTlvs_clone(this.ptr);
const ret_hu_conv = new UnauthenticatedReceiveTlvs(null, ret);
CommonBase.add_ref_from(ret_hu_conv, this);
return ret_hu_conv;
}
/**
* Creates an authenticated [`ReceiveTlvs`], which includes an HMAC and the provide [`Nonce`]
* that can be use later to verify it authenticity.
*/
authenticate(nonce, expanded_key) {
const ret = bindings.UnauthenticatedReceiveTlvs_authenticate(this.ptr, CommonBase.get_ptr_of(nonce), CommonBase.get_ptr_of(expanded_key));
const ret_hu_conv = new ReceiveTlvs(null, ret);
CommonBase.add_ref_from(ret_hu_conv, this);
CommonBase.add_ref_from(this, expanded_key);
return ret_hu_conv;
}
/**
* Serialize the UnauthenticatedReceiveTlvs object into a byte array which can be read by UnauthenticatedReceiveTlvs_read
*/
write() {
const ret = bindings.UnauthenticatedReceiveTlvs_write(this.ptr);
const ret_conv = bindings.decodeUint8Array(ret);
return ret_conv;
}
}
//# sourceMappingURL=UnauthenticatedReceiveTlvs.mjs.map