-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathverify
executable file
·38 lines (33 loc) · 1.24 KB
/
verify
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
#!/usr/bin/env coffee
{ log } = require 'lightsaber'
require 'shelljs/global'
bitcore = require 'bitcore'
Insight = require('bitcore-explorers').Insight
checkTruth = (error, info) ->
if error
console.error error
else
log info
log ''
{ balance, totalReceived, totalSent, unconfirmedBalance } = info
if balance is 0 and unconfirmedBalance is 0
log "---> awaiting claim"
else if balance is 0 and unconfirmedBalance > 0
log "---> awaiting network confirmation"
else if balance > 0 and totalSent is 0
log "---> claim maintained"
else if balance > 0 and totalSent > 0
log "---> claim revoked"
else
log "---> (claim state unknown)"
log ''
# Extract bitcoin address
getAddressFromCert = (cert) ->
certText = exec "openssl x509 -noout -text -in #{cert}", silent: true
# Subject: C=NO, ST=None, L=Aethers, O=OrgName, OU=n3kTRVniUF4zSx744JthxGh4qxnNYRnJqi, CN=www.mydomain.com
m = certText.output.match /\n\s+Subject:.*\bOU=(\w+)\b/
m[1]
address = getAddressFromCert "tmp/certs/www.mydomain.com.cert"
insight = new Insight 'https://test-insight.bitpay.com', bitcore.Networks.testnet
insight.address address, checkTruth
# look at that address' transaction's op return -- see that it matches