Skip to content

Instantly share code, notes, and snippets.

@hewigovens
Last active July 5, 2022 23:56
Show Gist options
  • Save hewigovens/bf8a509260684d8fcb738e2ce68a54e7 to your computer and use it in GitHub Desktop.
Save hewigovens/bf8a509260684d8fcb738e2ce68a54e7 to your computer and use it in GitHub Desktop.
Useful scripts for Trust Wallet Core
*~
.vscode
node_modules/
#!/usr/bin/env node
const { WalletCore } = require("@trustwallet/wallet-core");
const sleep = require("./sleep");
const readline = require("readline").createInterface({
input: process.stdin,
output: process.stdout,
});
const exportKin = () => {
const { HDWallet, CoinType, AnyAddress, HexCoding } = WalletCore;
readline.question('Please input your recovery phases to export private key for Kin:\n', phases => {
const wallet = HDWallet.createWithMnemonic(phases, "");
const key = wallet.getKeyForCoin(CoinType.kin);
const pubkey = key.getPublicKeyEd25519();
const kinAddress = wallet.getAddressForCoin(CoinType.kin);
const solAddress = AnyAddress.createWithPublicKey(pubkey, CoinType.solana);
console.log(`Key: ${HexCoding.encode(key.data())}`);
console.log(`Kin Address: ${kinAddress}`);
console.log(`SOL Address: ${solAddress.description()}`);
readline.close();
});
};
(async function () {
await sleep(1000);
exportKin();
})();
#!/usr/bin/env node
const { WalletCore } = require('@trustwallet/wallet-core');
const fs = require('fs');
const sleep = require('./sleep');
var wallets = [];
const genWallets = () => {
const { HDWallet, CoinType, HexCoding } = WalletCore;
var count = 10;
for (let index = 0; index < count; index++) {
const wallet = HDWallet.create(256, "");
const key = wallet.getKeyForCoin(CoinType.smartChain);
const address = wallet.getAddressForCoin(CoinType.smartChain);
wallets.push({
address: address,
mnemonic: wallet.mnemonic(),
key: HexCoding.encode(key.data())
});
}
writeCSV();
}
const writeCSV = () => {
var csv = "Address,Mnemonic,PrivateKey\n";
for (let index = 0; index < wallets.length; index++) {
const wallet = wallets[index];
csv += `${wallet.address},${wallet.mnemonic},${wallet.key}\n`;
}
fs.writeFileSync("wallets_3442.csv", csv);
}
(async function() {
await sleep(1000);
genWallets();
})();
{
"name": "wallet-gen",
"version": "1.0.0",
"description": "",
"main": "gen.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"@trustwallet/wallet-core": "^2.9.5"
}
}
module.exports = async (milliseconds) => {
await new Promise(resolve => setTimeout(resolve, milliseconds));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment