Skip to content

Instantly share code, notes, and snippets.

@williamcotton
Last active September 28, 2017 07:43
Show Gist options
  • Save williamcotton/6e15676e7084cfb92da9 to your computer and use it in GitHub Desktop.
Save williamcotton/6e15676e7084cfb92da9 to your computer and use it in GitHub Desktop.
document.getElementById("get-unspents").addEventListener("click", function(event) {
getUnspentOutputs = function(callback) {
xhr("https://www.blockai.com/chain/testnet/addresses/" + address + "/unspents", function(err, res, body) {
var unspentOutputs = JSON.parse(body);
unspentOutputs.forEach(function(utxo) {
utxo.txHash = utxo.hash;
utxo.index = utxo.outputIndex;
});
callback(err, unspentOutputs);
});
};
getUnspentOutputs(function(err, unspentOutputs) {
wallet.setUnspentOutputs(unspentOutputs);
unspentOutputsJSON = JSON.stringify(unspentOutputs, null, 4);
document.getElementById("unspent-outputs-json").innerHTML = unspentOutputsJSON;
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment