mirror of
https://github.com/tornadocash/tornado-core.git
synced 2024-11-22 17:50:19 +01:00
add balance
This commit is contained in:
parent
039cfa006c
commit
4817b2216e
@ -7,10 +7,11 @@
|
||||
1. `cp .env.example .env`
|
||||
1. `npm run build:circuit` - may take 10 minutes or more
|
||||
1. `npm run build:contract`
|
||||
1. `npx run ganache-cli`
|
||||
1. `npx ganache-cli`
|
||||
1. `npm run migrate:dev`
|
||||
1. `./cli.js deposit`
|
||||
1. `./cli.js withdraw <note from previous step> <destination eth address>`
|
||||
1. `./cli.js balance <destination eth address>`
|
||||
|
||||
## Testing truffle
|
||||
1. `npm i`
|
||||
|
11
cli.js
11
cli.js
@ -31,6 +31,11 @@ async function deposit() {
|
||||
return note;
|
||||
}
|
||||
|
||||
async function getBalance(receiver) {
|
||||
const balance = await web3.eth.getBalance(receiver)
|
||||
console.log('balance is ', web3.utils.fromWei(balance))
|
||||
}
|
||||
|
||||
async function withdraw(note, receiver) {
|
||||
let buf = Buffer.from(note.slice(2), "hex");
|
||||
let deposit = createDeposit(bigInt.leBuff2int(buf.slice(0, 32)), bigInt.leBuff2int(buf.slice(32, 64)));
|
||||
@ -140,7 +145,11 @@ if (inBrowser) {
|
||||
else
|
||||
printHelp(1);
|
||||
break;
|
||||
|
||||
case 'balance':
|
||||
if (args.length === 2 && /^0x[0-9a-fA-F]{40}$/.test(args[1])) {
|
||||
init().then(async () => getBalance(args[1])).then(() => process.exit(0)).catch(err => {console.log(err); process.exit(1)});
|
||||
}
|
||||
break
|
||||
case 'withdraw':
|
||||
if (args.length === 3 && /^0x[0-9a-fA-F]{128}$/.test(args[1]) && /^0x[0-9a-fA-F]{40}$/.test(args[2])) {
|
||||
init().then(async () => withdraw(args[1], args[2])).then(() => process.exit(0)).catch(err => {console.log(err); process.exit(1)});
|
||||
|
Loading…
Reference in New Issue
Block a user