-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcurrentAccounts.js
More file actions
37 lines (30 loc) · 1013 Bytes
/
currentAccounts.js
File metadata and controls
37 lines (30 loc) · 1013 Bytes
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
const request = require('superagent')
const config = require('./config')
const bitcoindRpc = require('./bitcoindRpc')
const currentAccounts = {}
// get all addresses I care about
function initializeWatchedAddresses(){
request
.get(config.brainLocation + 'members')
.end( (err, res)=> {
if (err || res.body.err){
return console.log('unable to get members, braindead')
}
res.body.forEach( member => initializeWatch(member.address) )
})
}
function initializeWatch(address){
if (!address) return console.log('address required')
bitcoindRpc.getBalance(address, (err, balance)=> {
if (err) return console.log('getbalance:', err);
console.log('getbalance:', {address, balance})
currentAccounts[address] = balance
})
}
// checkInitial('n2ywqjRRTdb9pfmRkDjag96TozUhBgvwww')
initializeWatchedAddresses()
module.exports = {
currentAccounts,
initializeWatch,
initializeWatchedAddresses
}