Skip to content

Commit

Permalink
api.bitindex.network is depricated. use api.mattercloud.net instead.
Browse files Browse the repository at this point in the history
  • Loading branch information
torusJKL committed Jan 31, 2020
1 parent 7ebd59a commit 163925c
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 26 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ var config = {
data: ["0x6d02", "hello from datapay"],
pay: {
key: "5JZ4RXH4MoXpaUQMcJHo8DxhZtkf5U5VnYd9zZH8BRKZuAbxZEw",
rpc: "https://api.bitindex.network",
rpc: "https://api.mattercloud.net",
fee: 400,
to: [{
address: "1A2JN4JAUoKCQ5kA4pHhu4qCqma8jZSU81",
Expand All @@ -101,7 +101,7 @@ Above config describes a transaction that:
- Posts `"hello from datapay"` to [memo.cash](https://memo.cash) network (See the protocol at [https://memo.cash/protocol](https://memo.cash/protocol)),
- paying the fee of `400` satoshis,
- signed with a private key: `5JZ4RXH4MoXpaUQMcJHo8DxhZtkf5U5VnYd9zZH8BRKZuAbxZEw`,
- through a public JSON-RPC endpoint at [https://api.bitindex.network](https://api.bitindex.network)
- through a public JSON-RPC endpoint at [https://api.mattercloud.net](https://api.mattercloud.net)
- while tipping the user `1A2JN4JAUoKCQ5kA4pHhu4qCqma8jZSU81` a value of `1000` satoshis.

All you need to do to invoke it is call:
Expand Down Expand Up @@ -301,15 +301,15 @@ datapay.build(tx, function(err, tx) {

The `rpc` attribute is used to manually set the JSON-RPC endpoint you wish to broadcast through.

- default: `https://api.bitindex.network`
- default: `https://api.mattercloud.net`

```
const tx = {
safe: true,
data: ["0x6d02", "hello world"],
pay: {
key: "5JZ4RXH4MoXpaUQMcJHo8DxhZtkf5U5VnYd9zZH8BRKZuAbxZEw",
rpc: "https://api.bitindex.network"
rpc: "https://api.mattercloud.net"
}
};
datapay.build(tx, function(err, res) {
Expand All @@ -332,7 +332,7 @@ const tx = {
data: ["0x6d02", "hello world"],
pay: {
key: "5JZ4RXH4MoXpaUQMcJHo8DxhZtkf5U5VnYd9zZH8BRKZuAbxZEw",
rpc: "https://api.bitindex.network",
rpc: "https://api.mattercloud.net",
fee: 400
}
}
Expand All @@ -356,7 +356,7 @@ const tx = {
data: ["0x6d02", "hello world"],
pay: {
key: "5JZ4RXH4MoXpaUQMcJHo8DxhZtkf5U5VnYd9zZH8BRKZuAbxZEw",
rpc: "https://api.bitindex.network",
rpc: "https://api.mattercloud.net",
feeb: 1.04
}
}
Expand Down Expand Up @@ -589,7 +589,7 @@ Using this endpoint you can connect to a public JSON-RPC endpoint to let you mak
datapay.connect([RPC ENDPOINT]).[METHOD]
```

If you leave the `RPC ENDPOINT` part out, it will automatically use the default https://api.bitindex.network node
If you leave the `RPC ENDPOINT` part out, it will automatically use the default https://api.mattercloud.net node

### Example 1: Connecting to default node and calling `getUnspentUtxos()` method:

Expand All @@ -606,7 +606,7 @@ datapay.connect().getUnspentUtxos("14xMz8rKm4L83RuZdmsHXD2jvENZbv72vR", function
### Example 2. Specifying a JSON-RPC endpoint

```
datapay.connect('https://api.bitindex.network').getUnspentUtxos("14xMz8rKm4L83RuZdmsHXD2jvENZbv72vR", function(err, utxos) {
datapay.connect('https://api.mattercloud.net').getUnspentUtxos("14xMz8rKm4L83RuZdmsHXD2jvENZbv72vR", function(err, utxos) {
if (err) {
console.log("Error: ", err)
} else {
Expand Down
22 changes: 15 additions & 7 deletions example/composer.html
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,10 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="https://unpkg.com/[email protected]/dist/datapay.min.js"></script>
<script>
var endpoint = "https://api.bitindex.network/api/tx/send";
var endpoint = "https://api.mattercloud.net/api/v3/main/tx/send"; // alternative: 'https://api.whatsonchain.com/v1/bsv/main/tx/raw'
var rawTxKey = 'rawtx'; // use 'txhex' for api.whatsonchain.com
var apiKey = ''; // only needed for api.mattercloud.net when exeeding 3 tx per 15 seconds.
// Get the API key from https://www.mattercloud.net/#get-api-key
document.addEventListener("DOMContentLoaded", function(event) {
var dslEl = document.querySelector("#dsl");
var txEl = document.querySelector("#tx");
Expand Down Expand Up @@ -109,20 +112,25 @@
update(dslEl.value)
})
var send = function(transaction) {
header = {
'Accept': 'application/json',
'Content-Type': 'application/json'
};

if (apiKey.length > 0)
header.apikey = apiKey;

fetch(endpoint, {
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
headers: header,
method: 'POST',
body: JSON.stringify({rawtx: transaction})
body: `{"${rawTxKey}": "${transaction.toString()}"}`
})
.then(function(res) {
return res.json();
})
.then(function(response) {
console.log(response);
document.querySelector("#sent").innerHTML = "<a href='https://api.bitindex.network/api/v2/tx/" + response.txid + "' target='_blank'>Success! Click to view Transaction</a>";
document.querySelector("#sent").innerHTML = "<a href='https://whatsonchain.com/tx/" + response.txid + "' target='_blank'>Success! Click to view Transaction</a>";
document.querySelector("#sent").className = "";
document.querySelector("#send").className = "hidden";
})
Expand Down
22 changes: 15 additions & 7 deletions example/playground.html
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,10 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="https://unpkg.com/[email protected]/dist/datapay.min.js"></script>
<script>
var endpoint = "https://api.bitindex.network/api/tx/send";
var endpoint = "https://api.mattercloud.net/api/v3/main/tx/send"; // alternative: 'https://api.whatsonchain.com/v1/bsv/main/tx/raw'
var rawTxKey = 'rawtx'; // use 'txhex' for api.whatsonchain.com
var apiKey = ''; // only needed for api.mattercloud.net when exeeding 3 tx per 15 seconds.
// Get the API key from https://www.mattercloud.net/#get-api-key
var transaction = null;
var selected = null;
var sending = false;
Expand Down Expand Up @@ -119,21 +122,26 @@
} else {
e.target.textContent = "Sending...";
sending = true;
header = {
'Accept': 'application/json',
'Content-Type': 'application/json'
};

if (apiKey.length > 0)
header.apikey = apiKey;

fetch(endpoint, {
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
headers: header,
method: 'POST',
body: JSON.stringify({rawtx: transaction.toString()})
body: `{"${rawTxKey}": "${transaction.toString()}"}`
})
.then(function(res) {
return res.json();
})
.then(function(response) {
console.log("Response = ", response)
e.target.textContent = "Sent!";
confirmEl.innerHTML = "<a href='https://api.bitindex.network/api/v2/tx/" + response.txid + "' target='_blank'>Success! Click to view Transaction</a>";
confirmEl.innerHTML = "<a href='https://whatsonchain.com/tx/" + response.txid + "' target='_blank'>Success! Click to view Transaction</a>";
})
}
}
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const _Buffer = require('buffer/')
const bitcoin = require('bsv');
const explorer = require('bitcore-explorers');
const defaults = {
rpc: "https://api.bitindex.network",
rpc: "api.mattercloud.net",
fee: 400,
feeb: 1.4
}
Expand Down
6 changes: 3 additions & 3 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -595,12 +595,12 @@ describe('datapay', function() {
it('default', function() {
var insight = datapay.connect();
assert.equal(insight.constructor.name, "Insight")
assert.equal(insight.url, 'https://api.bitindex.network')
assert.equal(insight.url, 'https://api.mattercloud.net')
})
it('connect with url', function() {
var insight = datapay.connect('https://api.bitindex.network');
var insight = datapay.connect('https://api.mattercloud.net');
assert.equal(insight.constructor.name, "Insight")
assert.equal(insight.url, 'https://api.bitindex.network')
assert.equal(insight.url, 'https://api.mattercloud.net')
})
})
})
Expand Down

0 comments on commit 163925c

Please sign in to comment.