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

3 years ago
  1. let button = document.getElementsByTagName('button')[0];
  2. button.addEventListener('click',gettx,false);
  3. function gettx() {
  4. let addr = document.getElementsByName('addr')[0].value;
  5. let url = api_url + 'gettx?addr=' + addr;
  6. document.getElementById('url').innerHTML = `<a href=${url}>${url}</a>`;
  7. let promised = fetch(url).
  8. then(resp => resp.json()).
  9. then(obj => {
  10. let elem = document.getElementById('json');
  11. elem.innerText = JSON.stringify(obj.tx);
  12. console.log('obj.tx',obj.tx);
  13. document.getElementById('txroot').innerText = obj.tx.txroot
  14. document.getElementById('pow').innerText = obj.tx.pow
  15. let list = ''
  16. for (let i of obj.tx.inputs) {
  17. public = Object.keys(i)[0];
  18. list += `<li>${public} ${i[public]}</li>`;
  19. }
  20. document.getElementById('in').innerHTML = list;
  21. list = ''
  22. for (let o of obj.tx.outputs) {
  23. public = Object.keys(o)[0];
  24. list += `<li>${public} ${o[public]}</li>`;
  25. }
  26. document.getElementById('out').innerHTML = list;
  27. list = ''
  28. for (let s of obj.tx.signatures) {
  29. public = Object.keys(s)[0];
  30. list += `<li>${public} ${s[public][0]}</li>`;
  31. }
  32. document.getElementById('sig').innerHTML = list;
  33. document.getElementById('yaml').innerText = obj.yaml;
  34. return obj;
  35. }).
  36. catch(console.error);
  37. promised.then(obj => { console.log('obj:',obj); return obj.tx; });
  38. }
  39. // ----------------------------------------------------
  40. console.log('transactions.js loaded');