You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.5 KiB
51 lines
1.5 KiB
|
|
let button = document.getElementsByTagName('button')[0];
|
|
button.addEventListener('click',gettx,false);
|
|
|
|
|
|
function gettx() {
|
|
|
|
let addr = document.getElementsByName('addr')[0].value;
|
|
let url = api_url + 'gettx?addr=' + addr;
|
|
document.getElementById('url').innerHTML = `<a href=${url}>${url}</a>`;
|
|
|
|
let promised = fetch(url).
|
|
then(resp => resp.json()).
|
|
then(obj => {
|
|
let elem = document.getElementById('json');
|
|
elem.innerText = JSON.stringify(obj.tx);
|
|
|
|
console.log('obj.tx',obj.tx);
|
|
document.getElementById('txroot').innerText = obj.tx.txroot
|
|
document.getElementById('pow').innerText = obj.tx.pow
|
|
|
|
let list = ''
|
|
for (let i of obj.tx.inputs) {
|
|
public = Object.keys(i)[0];
|
|
list += `<li>${public} ${i[public]}</li>`;
|
|
}
|
|
document.getElementById('in').innerHTML = list;
|
|
list = ''
|
|
for (let o of obj.tx.outputs) {
|
|
public = Object.keys(o)[0];
|
|
list += `<li>${public} ${o[public]}</li>`;
|
|
}
|
|
document.getElementById('out').innerHTML = list;
|
|
list = ''
|
|
for (let s of obj.tx.signatures) {
|
|
public = Object.keys(s)[0];
|
|
list += `<li>${public} ${s[public][0]}</li>`;
|
|
}
|
|
document.getElementById('sig').innerHTML = list;
|
|
|
|
document.getElementById('yaml').innerText = obj.yaml;
|
|
return obj;
|
|
}).
|
|
catch(console.error);
|
|
promised.then(obj => { console.log('obj:',obj); return obj.tx; });
|
|
|
|
}
|
|
|
|
|
|
// ----------------------------------------------------
|
|
console.log('transactions.js loaded');
|