forked from unwriter/datapay
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
api.bitindex.network is depricated. use api.mattercloud.net instead.
- Loading branch information
Showing
5 changed files
with
42 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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"); | ||
|
@@ -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"; | ||
}) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
|
@@ -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>"; | ||
}) | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters