Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
verifyKeyguardSignature(signedMessage, rawMessage) {
const signature = signedMessage.signature instanceof Nimiq.Signature ? signedMessage.signature : new Nimiq.Signature(signedMessage.signature);
const publicKey = signedMessage.signerPublicKey instanceof Nimiq.PublicKey ? signedMessage.signerPublicKey : new Nimiq.PublicKey(signedMessage.signerPublicKey);
const data = HubApi.MSG_PREFIX + rawMessage.length + rawMessage;
const dataBytes = Nimiq.BufferUtils.fromUtf8(data);
const hash = Nimiq.Hash.computeSha256(dataBytes);
return signature.verify(publicKey, hash);
}getTransactionByHash(hash, callback) {
if (this.theWrapper.nodeType == "FULL") {
let finalHash = null;
if (hash instanceof Nimiq.Hash) {
finalHash = hash;
} else if (typeof hash == "string") {
finalHash = Nimiq.Hash.fromHex(hash.replace("0x", ""));
}
if (finalHash == null) {
this.theWrapper.callbacks.error("UtilHelper:getTransactionByHash", NimiqWrapper.ERROR_MESSAGES.BAD_PARAM_TYPE);
} else {
this.theWrapper.wrappedNode.blockchain.getTransactionInfoByHash(finalHash).then((tx) => {
let obj = {
txHash : tx.transactionHash,
blockHash : tx.blockHash,
height : tx.blockHeight,
index : tx.index,
sender : tx.sender,
recipient : tx.recipientgetTransactionByHash(hash, callback) {
if (this.theWrapper.nodeType == "FULL") {
let finalHash = null;
if (hash instanceof Nimiq.Hash) {
finalHash = hash;
} else if (typeof hash == "string") {
finalHash = Nimiq.Hash.fromHex(hash.replace("0x", ""));
}
if (finalHash == null) {
this.theWrapper.callbacks.error("UtilHelper:getTransactionByHash", NimiqWrapper.ERROR_MESSAGES.BAD_PARAM_TYPE);
} else {
this.theWrapper.wrappedNode.blockchain.getTransactionInfoByHash(finalHash).then((tx) => {
let obj = {
txHash : tx.transactionHash,
blockHash : tx.blockHash,
height : tx.blockHeight,
index : tx.index,
sender : tx.sender,
recipient : tx.recipient
};
callback(obj);