Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return this.mempoolTxs.map(it => Nimiq.BufferUtils.toHex(it._hash._obj));
}importWalletFromHexKey(key) {
let privateKey = Nimiq.PrivateKey.unserialize(Nimiq.BufferUtils.fromHex(key.replace("0x", "")));
let keypair = Nimiq.KeyPair.derive(privateKey);
return new Nimiq.Wallet(keypair);
}let trackID = this.theWrapper.wrappedNode.mempool.on("transaction-added", (tx) => {
if (tx.sender.equals(watchAddr) || tx.recipient.equals(watchAddr)) {
if (!onlyMined) callback(tx, "mining");
let txHash = Nimiq.BufferUtils.toHex(tx._hash._obj);
let tracker = setInterval(() => {
if (!this.theWrapper.mempoolTxHashes.includes(txHash)) {
clearInterval(tracker);
callback(tx, "mined");
}
}, 1000);
}
});initMiner(options = { }) {
this.minerOptions = {
pool : true,
addr : Nimiq.Address.fromUserFriendlyAddress("NQ07 0000 0000 0000 0000 0000 0000 0000 0000"),
data : new Uint8Array(0),
host : "us.nimpool.io",
port : 8444
};
if (options.soloMine) this.minerOptions.pool = false;
if (options.poolHost) this.minerOptions.host = options.poolHost;
if (options.poolPort) this.minerOptions.port = options.poolPort;
if (options.extraData) {
if (typeof options.extraData == "string") {
this.minerOptions.data = Nimiq.BufferUtils.fromAscii(options.extraData);
} else if (options.extraData instanceof Uint8Array) {
this.minerOptions.data = options.extraData;
} else {
this.theWrapper.callbacks.error("MinerHelper:initMiner", NimiqWrapper.ERROR_MESSAGES.BAD_DATA);
}
}
if (options.address) {
if (options.address instanceof Nimiq.Wallet) {
this.minerOptions.addr = options.address.address;
} else if (options.address instanceof Nimiq.Address) {
this.minerOptions.addr = options.address;
} else if (typeof options.address == "string") {
this.minerOptions.addr = Nimiq.Address.fromUserFriendlyAddress(options.address);
} else {
this.theWrapper.callbacks.error("MinerHelper:initMiner", NimiqWrapper.ERROR_MESSAGES.BAD_ADDRESS);
}