How to use the @iota/core.generateAddress function in @iota/core

To help you get started, we’ve selected a few @iota/core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github iotaledger / industry-marketplace / ServiceApp / server / src / utils / walletHelper.ts View on Github external
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
github IOTA-Ledger / blue-app-iota / tests / bundle-generator / index.js View on Github external
function getAddress(seed, index, security) {
  return generateAddress(seed, index, security, false)
}
github iotaledger / industry-marketplace / ServiceApp / server / src / utils / walletHelper.ts View on Github external
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 {};
    }
};
github iotaledger / industry-marketplace / ServiceApp / server / src / utils / walletQueueHelper.ts View on Github external
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;
github iotaledger / industry-marketplace / ServiceApp / server / src / utils / walletQueueHelper.ts View on Github external
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) {
github iotaledger / poc-ipfs / api / src / routes / ipfsStore.ts View on Github external
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),
            [
                {