lightningdevkit
Version:
Lightning Development Kit
53 lines • 1.72 kB
JavaScript
import { CommonBase } from './CommonBase.mjs';
import * as bindings from '../bindings.mjs';
/**
* A hash for use in a specific context by tweaking with a context-dependent tag as per [BIP 340]
* and computed over the merkle root of a TLV stream to sign as defined in [BOLT 12].
*
* [BIP 340]: https://github.com/bitcoin/bips/blob/master/bip-0340.mediawiki
* [BOLT 12]: https://github.com/rustyrussell/lightning-rfc/blob/guilt/offers/12-offer-encoding.md#signature-calculation
*/
export class TaggedHash extends CommonBase {
/* @internal */
constructor(_dummy, ptr) {
super(ptr, bindings.TaggedHash_free);
}
clone_ptr() {
const ret = bindings.TaggedHash_clone_ptr(this.ptr);
return ret;
}
/**
* Creates a copy of the TaggedHash
*/
clone() {
const ret = bindings.TaggedHash_clone(this.ptr);
const ret_hu_conv = new TaggedHash(null, ret);
CommonBase.add_ref_from(ret_hu_conv, this);
return ret_hu_conv;
}
/**
* Returns the digest to sign.
*/
as_digest() {
const ret = bindings.TaggedHash_as_digest(this.ptr);
const ret_conv = bindings.decodeUint8Array(ret);
return ret_conv;
}
/**
* Returns the tag used in the tagged hash.
*/
tag() {
const ret = bindings.TaggedHash_tag(this.ptr);
const ret_conv = bindings.decodeString(ret);
return ret_conv;
}
/**
* Returns the merkle root used in the tagged hash.
*/
merkle_root() {
const ret = bindings.TaggedHash_merkle_root(this.ptr);
const ret_conv = bindings.decodeUint8Array(ret);
return ret_conv;
}
}
//# sourceMappingURL=TaggedHash.mjs.map