getumbrel / umbrel-middleware

RESTful Bitcoin and Lightning API for Umbrel
MIT License
21 stars 11 forks source link

Expose mempoolinfo and blockchaininfo #10

Closed nolim1t closed 4 years ago

nolim1t commented 4 years ago

Closes https://github.com/getumbrel/umbrel-middleware/issues/9 when done

nolim1t commented 4 years ago

Endpoints /info/sync (Expanded to expose extra stuff)

{
  "percent": "1.0000",
  "currentBlock": 627729,
  "headerCount": 627729,
  "difficulty": 15958652328578.42,
  "size": 311144972067
}

NEW! /info/mempool

{
  "loaded": true,
  "size": 4963,
  "bytes": 1860448,
  "usage": 7882624,
  "maxmempool": 512000000,
  "mempoolminfee": 1e-05,
  "minrelaytxfee": 1e-05
}
nolim1t commented 4 years ago

NEW info/stats (aka the firehouse)

{
  "blockchain_info": {
    "chain": "main",
    "blocks": 627732,
    "headers": 627732,
    "bestblockhash": "0000000000000000000dbc52d94673ab45b8271c38ec3245f82eb1a55bf10da3",
    "difficulty": 15958652328578.42,
    "mediantime": 1587917440,
    "verificationprogress": 0.9999987748965766,
    "initialblockdownload": false,
    "chainwork": "00000000000000000000000000000000000000000ee0e63b21634097f85357a4",
    "sizeOnDisk": 311149168631,
    "pruned": false,
    "softforks": {
      "bip34": {
        "type": "buried",
        "active": true,
        "height": 227931
      },
      "bip66": {
        "type": "buried",
        "active": true,
        "height": 363725
      },
      "bip65": {
        "type": "buried",
        "active": true,
        "height": 388381
      },
      "csv": {
        "type": "buried",
        "active": true,
        "height": 419328
      },
      "segwit": {
        "type": "buried",
        "active": true,
        "height": 481824
      }
    },
    "warnings": ""
  },
  "network_info": {
    "version": 190100,
    "subversion": "/Satoshi:0.19.1/",
    "protocolversion": 70015,
    "localservices": "0000000000000409",
    "localservicesnames": [
      "NETWORK",
      "WITNESS",
      "NETWORK_LIMITED"
    ],
    "localrelay": true,
    "timeoffset": -2,
    "networkactive": true,
    "connections": 10,
    "networks": [
      {
        "name": "ipv4",
        "limited": false,
        "reachable": true,
        "proxy": "",
        "proxyRandomizeCredentials": false
      },
      {
        "name": "ipv6",
        "limited": false,
        "reachable": true,
        "proxy": "",
        "proxyRandomizeCredentials": false
      },
      {
        "name": "onion",
        "limited": false,
        "reachable": true,
        "proxy": "127.0.0.1:9150",
        "proxyRandomizeCredentials": true
      }
    ],
    "relayfee": 1e-05,
    "incrementalfee": 1e-05,
    "localaddresses": [
      {
        "address": "3svpjvkmpftz2gny.onion",
        "port": 8333,
        "score": 7
      }
    ],
    "warnings": ""
  },
  "mempool": {
    "loaded": true,
    "size": 728,
    "bytes": 250136,
    "usage": 1135312,
    "maxmempool": 512000000,
    "mempoolminfee": 1e-05,
    "minrelaytxfee": 1e-05
  }
}
nolim1t commented 4 years ago

Please test @mayankchhabra

mayankchhabra commented 4 years ago

nice, I think you missed the hashrate

mayankchhabra commented 4 years ago

I also suggest removing all the other unrequired info from the stats endpoint because it can increase the request's response time, especially when the polling happens on tor

nolim1t commented 4 years ago

nice, I think you missed the hashrate

hashrate is difficulty

mayankchhabra commented 4 years ago

we need the network hashes per second... image

nolim1t commented 4 years ago

How is

{
  "blocks": 627734,
  "difficulty": 15958652328578.42,
  "size": 311151022856,
  "mempool": {
    "loaded": true,
    "size": 3889,
    "bytes": 1536424,
    "usage": 6171792,
    "maxmempool": 512000000,
    "mempoolminfee": 1e-05,
    "minrelaytxfee": 1e-05
  },
  "connections": 11
}

for mempool

mayankchhabra commented 4 years ago

sure but we still don't need a lot of it... just

{
    peers: <number of connected peers>
    mempool: <size of amempool in bytes>
    hashrate: <network hashes per second>
    blockchainSize: <the estimated size of the block and undo files on disk>
}

would be fine

nolim1t commented 4 years ago

Not sure what is what in mempool to be honest.

nolim1t commented 4 years ago

we need the network hashes per second... image

That might be challenging to get.. its not the same command and the library this is using is also unmaintained

nolim1t commented 4 years ago

found the function

nolim1t commented 4 years ago

However the hashes per second is not being returned from the library

nolim1t commented 4 years ago

so it might be a new function, added after they stopped maintaining

nolim1t commented 4 years ago
{
  "blocks": 627735,
  "difficulty": 15958652328578.42,
  "size": 311152526222,
  "mempool": {
    "loaded": true,
    "size": 4884,
    "bytes": 2023641,
    "usage": 7947472,
    "maxmempool": 512000000,
    "mempoolminfee": 1e-05,
    "minrelaytxfee": 1e-05
  },
  "connections": 10,
  "hashespersec": 109983984577136800000
}

However may require modifying upstream code which the last time it looks updated was June 2019

nolim1t commented 4 years ago

I can try to send a pull request (https://github.com/bitpay/bitcoind-rpc/pull/54) but I doubt anyone is maintaining it

mayankchhabra commented 4 years ago

ah I see, does it have bitcoin-cli getmininginfo? network hash ps is also returned in the mining info

nolim1t commented 4 years ago

From mining info

{
  "blocks": 627736,
  "difficulty": 15958652328578.42,
  "size": 311153957575,
  "mempool": {
    "loaded": true,
    "size": 4857,
    "bytes": 2377743,
    "usage": 8890432,
    "maxmempool": 512000000,
    "mempoolminfee": 1e-05,
    "minrelaytxfee": 1e-05
  },
  "connections": 10,
  "networkhashps": 109005941033200500000
}
mayankchhabra commented 4 years ago

Testing now

mayankchhabra commented 4 years ago

Tested and merged! Great job as always @nolim1t