jsir 1.0.3 → 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cmd/ethPrivateHit.js +45 -35
- package/cmd/ooa.js +773 -168
- package/ethWeb.js +5 -4
- package/index.js +10 -2
- package/package.json +4 -2
- package/sol.js +2 -1
- package/util.js +41 -7
- package/.idea/misc.xml +0 -9
- package/.idea/modules.xml +0 -8
- package/.idea/vcs.xml +0 -6
- package/.idea/workspace.xml +0 -382
package/cmd/ethPrivateHit.js
CHANGED
|
@@ -1,54 +1,64 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
let {run, coinNum, trim, getLibDataDir, lisPid, fileCleaner} = require('../index')
|
|
3
|
-
const Web3 = require("web3");
|
|
4
2
|
if (!process.argv[2]) {
|
|
5
|
-
console.log("http provider required")
|
|
3
|
+
console.log("web3 http provider required")
|
|
6
4
|
return
|
|
7
5
|
}
|
|
8
6
|
|
|
9
|
-
let
|
|
7
|
+
let {run, web3BatchReq, trim, createLimitLogger2, lisPid, timeStr, sleep, getOrFn} = require('../index')
|
|
8
|
+
const Web3 = require("web3");
|
|
10
9
|
let randomHex = require('randomhex');
|
|
11
10
|
|
|
12
|
-
let
|
|
13
|
-
|
|
14
|
-
let
|
|
11
|
+
let accountLog = createLimitLogger2('ethPrivateHit.account')
|
|
12
|
+
let recordLog = createLimitLogger2('ethPrivateHit.log')
|
|
13
|
+
let batchNum = 365
|
|
14
|
+
lisPid(`ethPrivateHit`)
|
|
15
|
+
let web3Map = {}
|
|
16
|
+
let web3 = new Web3()
|
|
15
17
|
|
|
16
|
-
let home = getLibDataDir()
|
|
17
|
-
let trysFile = `${home}/ethHitTrys.txt`
|
|
18
|
-
let privateFile = `${home}/ethPrivates.txt`
|
|
19
|
-
let errorFile = `${home}/ethHit.error`
|
|
20
|
-
lisPid("ethPrivateHit")
|
|
21
|
-
fileCleaner(errorFile)
|
|
22
18
|
run(async ()=>{
|
|
23
|
-
let
|
|
19
|
+
let trys = 1
|
|
24
20
|
while (true) {
|
|
21
|
+
await sleep(1)
|
|
25
22
|
try {
|
|
26
|
-
|
|
27
|
-
let
|
|
28
|
-
|
|
29
|
-
account.usdtBalance = coinNum(await usdtCon.methods.balanceOf(account.address).call(), 6)
|
|
30
|
-
account.balance = coinNum(await web3.eth.getBalance(account.address))
|
|
31
|
-
if ((account.balance + account.usdtBalance) > 0) {
|
|
32
|
-
log(`account: ${JSON.stringify(account, null, 2)}`)
|
|
23
|
+
let accounts = []
|
|
24
|
+
for(let i = 0; i<batchNum; i++) {
|
|
25
|
+
accounts.push(web3.eth.accounts.privateKeyToAccount(randomHex(32)))
|
|
33
26
|
}
|
|
34
|
-
|
|
27
|
+
for(let url of process.argv.slice(2)) {
|
|
28
|
+
let web3Obj = getOrFn(web3Map, url, () => {
|
|
29
|
+
return {web3: new Web3(trim(url))}
|
|
30
|
+
})
|
|
31
|
+
if (!web3Obj.chainId) {
|
|
32
|
+
web3Obj.chainId = await web3Obj.web3.eth.getChainId()
|
|
33
|
+
}
|
|
34
|
+
await processChain(accounts, web3Obj.web3, web3Obj.chainId, trys)
|
|
35
|
+
}
|
|
36
|
+
trys ++
|
|
35
37
|
} catch (e) {
|
|
36
|
-
|
|
38
|
+
recordLog(e)
|
|
37
39
|
}
|
|
38
40
|
}
|
|
39
41
|
})
|
|
40
42
|
|
|
41
|
-
function
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
43
|
+
async function processChain(accounts, web3, chainId, trys) {
|
|
44
|
+
let calls = []
|
|
45
|
+
for(let account of accounts) {
|
|
46
|
+
calls.push({
|
|
47
|
+
method: web3.eth.getBalance,
|
|
48
|
+
args: [account.address],
|
|
49
|
+
callback: (error, bal) => {
|
|
50
|
+
if (error) {
|
|
51
|
+
recordLog(error)
|
|
52
|
+
return
|
|
53
|
+
}
|
|
54
|
+
if (bal > 0) {
|
|
55
|
+
account.balance = bal
|
|
56
|
+
account.chainId = chainId
|
|
57
|
+
accountLog(`account: ${JSON.stringify(account, null, 2)}`)
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
})
|
|
53
61
|
}
|
|
62
|
+
await web3BatchReq(calls, 49, 9, web3)
|
|
63
|
+
recordLog(`${timeStr()}: ${chainId} ${trys * batchNum}`)
|
|
54
64
|
}
|