-
Notifications
You must be signed in to change notification settings - Fork 1
/
wallet-helper.js
59 lines (34 loc) · 949 Bytes
/
wallet-helper.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
const mongojs = require('mongojs')
var Web3 = require('web3')
let web3 = new Web3('ws://localhost:8546');
const mongoInterface = require('./mongo-interface')
const config = require("./config.json");
module.exports = {
async init()
{
mongoInterface.init('ethwalletbot')
},
async getETHAccount()
{
//.PUBLIC_ADDRESS .PRIVATE_KEY
return config.ETH_ACCT
}
async generateNewWallet(uid){
var acct = web3.eth.accounts.create();
await mongoInterface.insertOne('wallets',{uid: uid, acct: acct})
//save to mongo
return acct;
},
async deleteWallet(uid){
var result = await mongoInterface.deleteMany('wallets',{uid: uid})
//save to mongo
return result;
},
async findExistingWalletByUserID(uid)
{
//find in mongo
//var result = await db.ethwallets.findOne({uid:uid})
var result = await mongoInterface.findOne('wallets',{uid: uid})
return result;
}
}