lightningdevkit
Version:
Lightning Development Kit
43 lines • 1.54 kB
JavaScript
import { CommonBase } from './CommonBase.mjs';
import * as bindings from '../bindings.mjs';
class LDKEntropySourceHolder {
constructor() {
this.held = null;
}
}
/**
* A trait that describes a source of entropy.
*/
export class EntropySource extends CommonBase {
/* @internal */
constructor(_dummy, ptr) {
super(ptr, bindings.EntropySource_free);
this.bindings_instance = null;
}
/** Creates a new instance of EntropySource from a given implementation */
static new_impl(arg) {
const impl_holder = new LDKEntropySourceHolder();
let structImplementation = {
get_secure_random_bytes() {
const ret = arg.get_secure_random_bytes();
const result = bindings.encodeUint8Array(ret);
return result;
},
};
const ptr_idx = bindings.LDKEntropySource_new(structImplementation);
impl_holder.held = new EntropySource(null, ptr_idx[0]);
impl_holder.held.instance_idx = ptr_idx[1];
impl_holder.held.bindings_instance = structImplementation;
return impl_holder.held;
}
/**
* Gets a unique, cryptographically-secure, random 32-byte value. This method must return a
* different value each time it is called.
*/
get_secure_random_bytes() {
const ret = bindings.EntropySource_get_secure_random_bytes(this.ptr);
const ret_conv = bindings.decodeUint8Array(ret);
return ret_conv;
}
}
//# sourceMappingURL=EntropySource.mjs.map