Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return new Promise((resolve, reject) => {
const remainderAddress = generateAddress(seed, keyIndex + 1);
const options = {
inputs: [{
address,
keyIndex,
security,
balance
}],
security,
remainderAddress
};
prepareTransfers(seed, transfers, options)
.then(async trytes => {
sendTrytes(trytes, depth, minWeightMagnitude)
.then(async transactions => {
// Before the payment is confirmed update the wallet with new address and index, calculate expected balance
function getAddress(seed, index, security) {
return generateAddress(seed, index, security, false)
}
export const generateNewWallet = () => {
try {
const seed = generateSeed();
const address = generateAddress(seed, 0, 2, true);
return { seed, address, keyIndex: 0, balance: 0 };
} catch (error) {
console.error('generateNewWallet error', error);
return {};
}
};
return new Promise(async (resolve, reject) => {
const repair = await generateAddress(seed, keyIndex, 2, true)
console.log("Repairing address", repair)
await updateValue('wallet', 'seed', 'status', seed, 'error')
let iterable = [-4, -3, -2, -1, 0, 1, 2, 3, 4];
for (let value of iterable) {
if ((value < 0 && Math.abs(value) <= keyIndex) || value >= 0) {
const newIndex = Number(keyIndex) + Number(value)
const newAddress = await generateAddress(seed, newIndex, 2, true)
const balance = await getBalance(newAddress);
if (balance > 0) {
await writeData('wallet', { address: newAddress, balance, keyIndex: newIndex, seed, status: 'usable' });
resolve();
}
}
value += 1;
return new Promise(async (resolve, reject) => {
const repair = await generateAddress(seed, keyIndex, 2, true)
console.log("Repairing address", repair)
await updateValue('wallet', 'seed', 'status', seed, 'error')
let iterable = [-4, -3, -2, -1, 0, 1, 2, 3, 4];
for (let value of iterable) {
if ((value < 0 && Math.abs(value) <= keyIndex) || value >= 0) {
const newIndex = Number(keyIndex) + Number(value)
const newAddress = await generateAddress(seed, newIndex, 2, true)
const balance = await getBalance(newAddress);
if (balance > 0) {
await writeData('wallet', { address: newAddress, balance, keyIndex: newIndex, seed, status: 'usable' });
resolve();
}
}
value += 1;
}
resolve();
});
} catch (error) {
currentState = {
seed: TrytesHelper.generateHash(),
id: "default",
addressIndex: 0
};
} else {
currentState.addressIndex++;
}
await stateService.set(currentState);
const iota = composeAPI({
provider: config.node.provider
});
const nextAddress = generateAddress(currentState.seed, currentState.addressIndex, 2);
const tanglePayload: IPayload = {
name: request.name,
description: request.description,
size: request.size,
modified: request.modified,
algorithm: request.algorithm,
hash: request.hash,
ipfs: addResponse[0].hash
};
console.log(`Prepare Transfer`);
const trytes = await iota.prepareTransfers(
"9".repeat(81),
[
{