-
Notifications
You must be signed in to change notification settings - Fork 1
/
fetchNetworkInfo.js
32 lines (24 loc) · 958 Bytes
/
fetchNetworkInfo.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
// Google Docs JS Macro to fetch data about the bitcoin network
// Written by [email protected], tips to: 1ZnortsoStC1zSTXbW6CUtkvqew8czMMG
function fetchDifficulty()
{
// Fetch live data from blockchain.info
var data = UrlFetchApp.fetch('http://blockchain.info/q/getdifficulty')
if ('undefined' == typeof(data))
return 'Could not fetch difficulty from blockchain.info'
data = data.getContentText()
if (data.length<=0)
return 'blockchain.info returned invalid data for getdifficulty'
return data
}
function fetchNextDifficultyEstimate()
{
// Fetch live data from blockchain.info
var data = UrlFetchApp.fetch('http://blockexplorer.com/q/estimate')
if ('undefined' == typeof(data))
return 'Could not fetch difficulty from blockexplorer.com'
data = data.getContentText()
if (data.length<=0)
return 'blockexplorer.com returned invalid data for getdifficulty'
return data
}