// get op-return values with blockcypher
//
// notes: fork https://runkit.com/makevoid/eternity-wall-json-opreturn
const http = require('axios')
const c = console
const DEBUG = true // enables console.log
// const DEBUG = false
const url_base = "api.blockcypher.com/v1/btc/main"
// specify your address
//
const address = "12RXhCqxnXgJyfJLL2mvcqT3jCQ2o6rMAR"
const endpoint = `addrs/${address}/full`
const url = `https://${url_base}/${endpoint}`
if (DEBUG) c.log(`URL: ${url}`)
const resp = await http.get(url)
if (DEBUG) c.log(resp.data)
// API returns only the first message - TODO FIXME api
resp.data.txs.select((tx) => {
return tx.data_protocol == "unknown"
}).map((tx) => {
return tx
})
// other OP_RETURN
// http://api.coinsecrets.org/block/353197 - http://api.coinsecrets.org/block/NUMBER ( need to scan all the blocks from x to y - needs caching - background task - request limited - 1rps by api policy rules - use redis cache maybe? )