Comparing version 0.0.2 to 0.0.3
@@ -5,5 +5,5 @@ <img class='logo' src='MINERCRAFT.png'> | ||
[GitHub](https://github.com/docsifyjs/docsify/) | ||
[Get Started](#quick-start) | ||
[GitHub](https://github.com/interplanaria/minercraft) | ||
[Get Started](#minercraft) | ||
![](mm.jpg) |
@@ -7,6 +7,6 @@ /******************************************************************** | ||
const Minercraft = require('../index'); | ||
const Player = require('./miners.json'); | ||
const Miners = require('./miners.json'); | ||
(async () => { | ||
for(let name in Player) { | ||
let config = Player[name]; | ||
for(let name in Miners) { | ||
let config = Miners[name]; | ||
const miner = new Minercraft(config) | ||
@@ -13,0 +13,0 @@ const rate = await miner.fee.rate() |
@@ -7,6 +7,6 @@ /******************************************************************** | ||
const Minercraft = require('../index'); | ||
const Player = require('./miners.json'); | ||
const Miners = require('./miners.json'); | ||
(async () => { | ||
for(let name in Player) { | ||
let config = Player[name]; | ||
for(let name in Miners) { | ||
let config = Miners[name]; | ||
const miner = new Minercraft(config) | ||
@@ -13,0 +13,0 @@ const rate = await miner.fee.rate() |
const bsv = require('bsv') | ||
const Minercraft = require('../index'); | ||
const Player = require('./miners.json'); | ||
const Miners = require('./miners.json'); | ||
(async () => { | ||
let t = new bsv.Transaction() | ||
for(let name in Player) { | ||
let config = Player[name]; | ||
for(let name in Miners) { | ||
let config = Miners[name]; | ||
const miner = new Minercraft(config) | ||
@@ -9,0 +9,0 @@ const rate = await miner.fee.rate() |
@@ -7,6 +7,6 @@ /******************************************************************** | ||
const Minercraft = require('../index'); | ||
const Player = require('./miners.json'); | ||
const Miners = require('./miners.json'); | ||
(async () => { | ||
for(let name in Player) { | ||
let config = Player[name]; | ||
for(let name in Miners) { | ||
let config = Miners[name]; | ||
const miner = new Minercraft(config) | ||
@@ -13,0 +13,0 @@ const txid = "177b4087cf6ef58e7a93a2791762688a848edbc5169166bc4fd128fba84ff8ba" |
23
fee.js
@@ -11,3 +11,3 @@ const bsv = require('bsv') | ||
} | ||
rate() { | ||
rate(options) { | ||
if (this.url) { | ||
@@ -18,10 +18,15 @@ let u = this.url + (this.ratePath ? this.ratePath : "") | ||
let response = JSON.parse(res.data.payload) | ||
let fees = {} | ||
response.fees.forEach((f) => { | ||
fees[f.feeType] = { | ||
mine: f.miningFee.satoshis/f.miningFee.bytes, | ||
relay: f.relayFee.satoshis/f.relayFee.bytes | ||
} | ||
}) | ||
return fees | ||
if (options && options.verbose) { | ||
res.data.payload = response | ||
return res.data; | ||
} else { | ||
let fees = {} | ||
response.fees.forEach((f) => { | ||
fees[f.feeType] = { | ||
mine: f.miningFee.satoshis/f.miningFee.bytes, | ||
relay: f.relayFee.satoshis/f.relayFee.bytes | ||
} | ||
}) | ||
return fees | ||
} | ||
}) | ||
@@ -28,0 +33,0 @@ } else { |
{ | ||
"name": "minercraft", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "interact with bitcoin miner apis", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -26,7 +26,7 @@ # Minercraft | ||
- Matterpool: https://matterpool.io | ||
- Mempool: https://mempool.com | ||
- TAAL: https://taal.com | ||
- YOU CAN TOO! | ||
- YOU CAN TOO! (Please give a heads up to [@_unwriter](https://twitter.com/_unwriter) when you implement the API) | ||
--- | ||
@@ -42,4 +42,6 @@ | ||
Check out a in-browser demo here: [Minercraft Browser Demo](demo/webdemo.html) | ||
Check out an in-browser demo here: [Minercraft Browser Demo](https://minercraft.network/demo/webdemo.html) (Source code [here](https://github.com/interplanaria/minercraft/blob/master/demo/webdemo.html)) | ||
## 2. In node.js | ||
@@ -81,3 +83,3 @@ | ||
You can use the following config to connect to TAAL merchant API (Tentative): | ||
You can use the following config to connect to Mempool.com merchant API (Tentative): | ||
@@ -95,3 +97,12 @@ ``` | ||
### c. Matterpool.io | ||
You can use the following config to connect to Matterpool.io merchant API: | ||
``` | ||
const miner = new Minercraft({ | ||
url: "https://merchantapi.matterpool.io", | ||
}) | ||
``` | ||
## 1. Get the fee rate | ||
@@ -117,3 +128,3 @@ | ||
Calculate a fixed rate: | ||
Calculate total fee, based on a fixed rate: | ||
@@ -171,2 +182,3 @@ ```javascript | ||
Pass a raw transaction hex string into the `push()` function and it will send the transaction directly to the miner. | ||
@@ -173,0 +185,0 @@ ```javascript |
@@ -11,3 +11,3 @@ const axios = require('axios') | ||
} | ||
push(rawtx) { | ||
push(rawtx, options) { | ||
if (this.url) { | ||
@@ -18,3 +18,8 @@ let u = this.url + (this.pushPath ? this.pushPath : "") | ||
}).then((res) => { | ||
return JSON.parse(res.data.payload) | ||
if (options && options.verbose) { | ||
res.data.payload = JSON.parse(res.data.payload) | ||
return res.data | ||
} else { | ||
return JSON.parse(res.data.payload) | ||
} | ||
}) | ||
@@ -25,7 +30,12 @@ } else { | ||
} | ||
status(id) { | ||
status(id, options) { | ||
if (this.url) { | ||
let u = this.url + (this.statusPath ? this.statusPath : "") + "/" + id | ||
return axios.get(u, { headers: this.headers }).then((res) => { | ||
return JSON.parse(res.data.payload) | ||
if (options && options.verbose) { | ||
res.data.payload = JSON.parse(res.data.payload) | ||
return res.data | ||
} else { | ||
return JSON.parse(res.data.payload) | ||
} | ||
}) | ||
@@ -32,0 +42,0 @@ } else { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6257503
26
36493
182