lightningdevkit
Version:
Lightning Development Kit
92 lines • 3.46 kB
JavaScript
import { Result_DNSResolverContextDecodeErrorZ } from '../structs/Result_DNSResolverContextDecodeErrorZ.mjs';
import { CommonBase } from './CommonBase.mjs';
import * as bindings from '../bindings.mjs';
/**
* Contains a simple nonce for use in a blinded path's context.
*
* Such a context is required when receiving a [`DNSSECProof`] message.
*
* [`DNSSECProof`]: crate::onion_message::dns_resolution::DNSSECProof
*/
export class DNSResolverContext extends CommonBase {
/* @internal */
constructor(_dummy, ptr) {
super(ptr, bindings.DNSResolverContext_free);
}
/**
* A nonce which uniquely describes a DNS resolution.
*
* When we receive a DNSSEC proof message, we should check that it was sent over the blinded
* path we included in the request by comparing a stored nonce with this one.
*/
get_nonce() {
const ret = bindings.DNSResolverContext_get_nonce(this.ptr);
const ret_conv = bindings.decodeUint8Array(ret);
return ret_conv;
}
/**
* A nonce which uniquely describes a DNS resolution.
*
* When we receive a DNSSEC proof message, we should check that it was sent over the blinded
* path we included in the request by comparing a stored nonce with this one.
*/
set_nonce(val) {
bindings.DNSResolverContext_set_nonce(this.ptr, bindings.encodeUint8Array(val));
}
/**
* Constructs a new DNSResolverContext given each field
*/
static constructor_new(nonce_arg) {
const ret = bindings.DNSResolverContext_new(bindings.encodeUint8Array(nonce_arg));
const ret_hu_conv = new DNSResolverContext(null, ret);
CommonBase.add_ref_from(ret_hu_conv, ret_hu_conv);
return ret_hu_conv;
}
clone_ptr() {
const ret = bindings.DNSResolverContext_clone_ptr(this.ptr);
return ret;
}
/**
* Creates a copy of the DNSResolverContext
*/
clone() {
const ret = bindings.DNSResolverContext_clone(this.ptr);
const ret_hu_conv = new DNSResolverContext(null, ret);
CommonBase.add_ref_from(ret_hu_conv, this);
return ret_hu_conv;
}
/**
* Generates a non-cryptographic 64-bit hash of the DNSResolverContext.
*/
hash() {
const ret = bindings.DNSResolverContext_hash(this.ptr);
return ret;
}
/**
* Checks if two DNSResolverContexts 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.DNSResolverContext_eq(this.ptr, CommonBase.get_ptr_of(b));
CommonBase.add_ref_from(this, b);
return ret;
}
/**
* Serialize the DNSResolverContext object into a byte array which can be read by DNSResolverContext_read
*/
write() {
const ret = bindings.DNSResolverContext_write(this.ptr);
const ret_conv = bindings.decodeUint8Array(ret);
return ret_conv;
}
/**
* Read a DNSResolverContext from a byte array, created by DNSResolverContext_write
*/
static constructor_read(ser) {
const ret = bindings.DNSResolverContext_read(bindings.encodeUint8Array(ser));
const ret_hu_conv = Result_DNSResolverContextDecodeErrorZ.constr_from_ptr(ret);
return ret_hu_conv;
}
}
//# sourceMappingURL=DNSResolverContext.mjs.map