mirror of
https://github.com/tornadocash/tornado-cli.git
synced 2024-11-22 01:37:08 +01:00
Fix bug & Show remote ip from console
This commit is contained in:
parent
80a810e727
commit
710054547a
15
cli.js
15
cli.js
@ -894,11 +894,13 @@ async function init({ rpc, noteNetId, currency = 'dai', amount = '100', torPort,
|
|||||||
TOKEN_AMOUNT = 1e19
|
TOKEN_AMOUNT = 1e19
|
||||||
senderAccount = (await web3.eth.getAccounts())[0]
|
senderAccount = (await web3.eth.getAccounts())[0]
|
||||||
} else {
|
} else {
|
||||||
|
let ipOptions = {};
|
||||||
if (torPort) {
|
if (torPort) {
|
||||||
console.log("Using tor network")
|
console.log("Using tor network")
|
||||||
web3Options = { agent: { https: new SocksProxyAgent('socks5h://127.0.0.1:'+torPort) }, timeout: 60000 }
|
web3Options = { agent: { https: new SocksProxyAgent('socks5h://127.0.0.1:'+torPort) }, timeout: 60000 }
|
||||||
// Use forked web3-providers-http from local file to modify user-agent header value which improves privacy.
|
// Use forked web3-providers-http from local file to modify user-agent header value which improves privacy.
|
||||||
web3 = new Web3(new Web3HttpProvider(rpc, web3Options), null, { transactionConfirmationBlocks: 1 })
|
web3 = new Web3(new Web3HttpProvider(rpc, web3Options), null, { transactionConfirmationBlocks: 1 })
|
||||||
|
ipOptions = { httpsAgent: new SocksProxyAgent('socks5h://127.0.0.1:'+torPort), headers: { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; rv:91.0) Gecko/20100101 Firefox/91.0' } }
|
||||||
} else if (rpc.includes("ipc")) {
|
} else if (rpc.includes("ipc")) {
|
||||||
console.log("Using ipc connection")
|
console.log("Using ipc connection")
|
||||||
web3 = new Web3(new Web3.providers.IpcProvider(rpc, net), null, { transactionConfirmationBlocks: 1 })
|
web3 = new Web3(new Web3.providers.IpcProvider(rpc, net), null, { transactionConfirmationBlocks: 1 })
|
||||||
@ -910,6 +912,9 @@ async function init({ rpc, noteNetId, currency = 'dai', amount = '100', torPort,
|
|||||||
console.log("Connecting to remote node")
|
console.log("Connecting to remote node")
|
||||||
web3 = new Web3(rpc, null, { transactionConfirmationBlocks: 1 })
|
web3 = new Web3(rpc, null, { transactionConfirmationBlocks: 1 })
|
||||||
}
|
}
|
||||||
|
const fetchRemoteIP = await axios.get('https://ip.tornado.cash', ipOptions)
|
||||||
|
const { country, ip } = fetchRemoteIP.data
|
||||||
|
console.log('Your remote IP address is',ip,'from',country+'.');
|
||||||
contractJson = require('./build/contracts/TornadoProxy.abi.json')
|
contractJson = require('./build/contracts/TornadoProxy.abi.json')
|
||||||
instanceJson = require('./build/contracts/Instance.abi.json')
|
instanceJson = require('./build/contracts/Instance.abi.json')
|
||||||
circuit = require('./build/circuits/tornado.json')
|
circuit = require('./build/circuits/tornado.json')
|
||||||
@ -918,10 +923,12 @@ async function init({ rpc, noteNetId, currency = 'dai', amount = '100', torPort,
|
|||||||
ETH_AMOUNT = process.env.ETH_AMOUNT
|
ETH_AMOUNT = process.env.ETH_AMOUNT
|
||||||
TOKEN_AMOUNT = process.env.TOKEN_AMOUNT
|
TOKEN_AMOUNT = process.env.TOKEN_AMOUNT
|
||||||
const privKey = process.env.PRIVATE_KEY
|
const privKey = process.env.PRIVATE_KEY
|
||||||
if (privKey.includes("0x")) {
|
if (privKey) {
|
||||||
PRIVATE_KEY = process.env.PRIVATE_KEY.substring(2)
|
if (privKey.includes("0x")) {
|
||||||
} else {
|
PRIVATE_KEY = process.env.PRIVATE_KEY.substring(2)
|
||||||
PRIVATE_KEY = process.env.PRIVATE_KEY
|
} else {
|
||||||
|
PRIVATE_KEY = process.env.PRIVATE_KEY
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (PRIVATE_KEY) {
|
if (PRIVATE_KEY) {
|
||||||
const account = web3.eth.accounts.privateKeyToAccount('0x' + PRIVATE_KEY)
|
const account = web3.eth.accounts.privateKeyToAccount('0x' + PRIVATE_KEY)
|
||||||
|
Loading…
Reference in New Issue
Block a user