Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
module.exports = delegatesConfig.secrets.map(secret => {
const publicKey = crypto.getKeys(secret).publicKey
const address = crypto.getAddress(publicKey)
const balance = genesisTransactions.find(
transaction =>
transaction.recipientId === address && transaction.type === 0,
).amount
return {
secret,
passphrase: secret, // just an alias for delegate secret
publicKey,
address,
balance,
}
})
public async run(): Promise {
const { flags } = this.parse(IdentityCommand);
configManager.setFromPreset(flags.network as NetworkName);
let output;
if (flags.type === "passphrase") {
const keys = crypto.getKeys(flags.data);
output = {
passphrase: flags.data,
publicKey: keys.publicKey,
privateKey: keys.privateKey,
address: crypto.getAddress(keys.publicKey),
};
} else if (flags.type === "privateKey") {
const keys = crypto.getKeysByPrivateKey(flags.data);
output = {
publicKey: keys.publicKey,
privateKey: keys.privateKey,
address: crypto.getAddress(keys.publicKey),
};
} else if (flags.type === "publicKey") {
output = {
publicKey: flags.data,
async run(options) {
this.options = { ...this.options, ...options }
const primaryAddress = crypto.getAddress(
crypto.getKeys(this.config.passphrase).publicKey,
this.config.network.version,
)
let wallets = this.options.wallets
if (wallets === undefined) {
wallets = this.generateWallets()
}
logger.info(
`Sending ${wallets.length} transfer ${pluralize(
'transaction',
wallets.length,
true,
)}`,
)
let secondPassphrase;
if (typeof passphrase === "object") {
secondPassphrase = passphrase.secondPassphrase;
passphrase = passphrase.passphrase;
}
client.getConfigManager().setFromPreset(network);
const transactions = [];
for (let i = 0; i < quantity; i++) {
let builder: any = client.getBuilder();
switch (type) {
case Transfer: {
if (!addressOrPublicKeyOrUsername) {
addressOrPublicKeyOrUsername = crypto.getAddress(crypto.getKeys(passphrase).publicKey);
}
builder = builder
.transfer()
.recipientId(addressOrPublicKeyOrUsername)
.amount(amount)
.vendorField(`Test Transaction ${i + 1}`);
break;
}
case SecondSignature: {
builder = builder.secondSignature().signatureAsset(passphrase);
break;
}
case DelegateRegistration: {
const username =
addressOrPublicKeyOrUsername ||
superheroes
public async run(): Promise {
await this.initialize(TransferCommand);
const primaryAddress = crypto.getAddress(
crypto.getKeys(this.config.passphrase).publicKey,
this.config.network.version,
);
let wallets = this.options.wallets;
if (wallets === undefined) {
wallets = this.generateWallets();
}
logger.info(`Sending ${wallets.length} transfer ${pluralize("transaction", wallets.length)}`);
const walletBalance = await this.getWalletBalance(primaryAddress);
if (!this.options.skipValidation) {
logger.info(`Sender starting balance: ${satoshiToArk(walletBalance)}`);
}
export const generateWallets = (network, quantity = 10) => {
network = network || "testnet";
if (!["testnet", "mainnet", "devnet", "unitnet"].includes(network)) {
throw new Error("Invalid network");
}
client.getConfigManager().setFromPreset(network);
const wallets = [];
for (let i = 0; i < quantity; i++) {
const passphrase = bip39.generateMnemonic();
const publicKey = crypto.getKeys(passphrase).publicKey;
const address = crypto.getAddress(publicKey);
wallets.push({ address, passphrase, publicKey });
}
return wallets;
};
public __createWallet() {
const passphrase = bip39.generateMnemonic();
const keys = crypto.getKeys(passphrase);
return {
address: crypto.getAddress(keys.publicKey, this.prefixHash),
passphrase,
keys,
};
}
async method(params) {
try {
const { keys, wif } = await getBIP38Wallet(params.userId, params.bip38);
return {
publicKey: keys.publicKey,
address: crypto.getAddress(keys.publicKey),
wif,
};
} catch (error) {
const { publicKey, privateKey } = crypto.getKeys(bip39.generateMnemonic());
const encryptedWIF = bip38.encrypt(Buffer.from(privateKey, "hex"), true, params.bip38 + params.userId);
await database.set(HashAlgorithms.sha256(Buffer.from(params.userId)).toString("hex"), encryptedWIF);
const { wif } = decryptWIF(encryptedWIF, params.userId, params.bip38);
return {
publicKey,
address: crypto.getAddress(publicKey),
wif,
};
}
},
schema: {