Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
switch api provider
Browse files Browse the repository at this point in the history
change utxo api provider back to blockchair
  • Loading branch information
coinables committed Dec 3, 2021
1 parent f3076cf commit 7c0bd56
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
27 changes: 17 additions & 10 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,10 @@
width: 140px;
float: right;
}
.smalltxt{
font-size: 10px;
color: #888;
}
</style>

<!-- jQuery -->
Expand All @@ -176,7 +180,7 @@
<!-- QRCode lib -->
<script type="text/javascript" src="js/qrcode.js"></script>
<!-- Network specific methods -->
<script type="text/javascript" src="js/network.js"></script>
<script type="text/javascript" src="js/network.js?s=1"</script>
</head>

<body>
Expand Down Expand Up @@ -230,6 +234,7 @@

<!-- Sweep Key -->
<h2>Sweep SegWit Private Key</h2>
<em class="smalltxt">UTXO data provided by <a href="https://blockchair.com/api/">Blockchair.com</a></em>
<div id="sweepcont">
<input type="password" class="form-control input-lg" placeholder="SegWit Private Key" id="wifprivatekey"><button class="btn btn-default" onClick="return turnOnWC();">SCAN WITH WEBCAM</button><span id="qrnotify" class="label label-success">QR CODE SCANNED</span>
<video id="qrcam"></video>
Expand Down Expand Up @@ -508,7 +513,7 @@ <h2>Details</h2>

function sweepKey() {
var NETWORK = currentNetwork();
var API_DOMAIN = apiDomain();

var EXPLORER_DOMAIN = explorerDomain();
var Buffer = null

Expand Down Expand Up @@ -538,21 +543,23 @@ <h2>Details</h2>
var redeemScriptHash = bitcoin.crypto.hash160(redeemScript);
var scriptPubKey = bitcoin.script.scriptHash.output.encode(redeemScriptHash);
var P2SHAddress = bitcoin.address.fromOutputScript(scriptPubKey, NETWORK);

var NETWORKAPI = isTestNet ? "testnet/" : "";

//console.log(P2SHAddress);
//get UTXOs for address of private key
var data
$.ajax({
async: true,
type: "GET",
url: API_DOMAIN + "/v1/blockchain/address/" + P2SHAddress + "/unspent",
url: "https://api.blockchair.com/bitcoin/"+NETWORKAPI+"dashboards/address/"+P2SHAddress,
success: function(result) {
console.log(result.unspent.length + " utxos found");
data = result.unspent.map(function(item){
console.log(result.data[P2SHAddress].utxo.length + " utxos found");
data = result.data[P2SHAddress].utxo.map(function(item){
return {
"txid": item.txid,
"vout": item.n,
"satoshis": item.value_int
"txid": item.transaction_hash,
"vout": item.index,
"satoshis": item.value
}
})
//output response into the inputdata element
Expand Down Expand Up @@ -627,10 +634,10 @@ <h2>Details</h2>
$.ajax({
async: true,
type: "POST",
url: API_DOMAIN + "/v1/blockchain/pushtx",
url: "https://api.blockchair.com/bitcoin/"+NETWORKAPI+"push/transaction",
contentType: 'application/json',
dataType: "json",
data: JSON.stringify({hex: tx_raw}),
data: JSON.stringify({data: tx_raw}),
success: function(result) {
console.log("Transaction sent!");
}
Expand Down
4 changes: 2 additions & 2 deletions js/network.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ function headerHtml() {
}

function apiDomain() {
return isTestNet ? 'https://testnet-api.smartbit.com.au' : 'https://api.smartbit.com.au';

}

function explorerDomain() {
return isTestNet ? 'https://testnet.smartbit.com.au' : 'https://www.smartbit.com.au';
return isTestNet ? 'https://live.blockcypher.com/btc-testnet' : 'https://live.blockcypher.com/btc';
}

0 comments on commit 7c0bd56

Please sign in to comment.