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.
53 lines
1.3 KiB
53 lines
1.3 KiB
|
|
let button = document.getElementById('submit');
|
|
button.addEventListener('click',createtx,false);
|
|
|
|
loadtx('templ/txexample.yml');
|
|
|
|
function createtx() {
|
|
|
|
let txyml = document.getElementsByName('tx').value;
|
|
|
|
let promised = fetch(api_url + 'settx?',{method:'POST',data}).
|
|
then(resp => resp.json()).
|
|
then(obj => {
|
|
|
|
elem = document.getElementById('json');
|
|
elem.innerText = JSON.stringify(obj);
|
|
|
|
let bkcontent = obj.bkcontent;
|
|
let txmerkle = bkcontent.txmeta.merkle
|
|
if (typeof(txmerkle) != 'undefined') {
|
|
let list = '<ul>';
|
|
for (let txa of txmerkle) {
|
|
console.log('getblock.txa:',txa);
|
|
let tx_url = api_url + `gettx?addr=${txa}`
|
|
list += `<li><a href="${tx_url}">${txa}</a></li>`
|
|
}
|
|
list += '</ul>';
|
|
elem = document.getElementById('list');
|
|
elem.innerHTML = list;
|
|
}
|
|
|
|
return obj;
|
|
}).
|
|
catch(console.error);
|
|
promised.then(obj => { console.log('obj:',obj); return obj; });
|
|
|
|
}
|
|
|
|
function loadtx(f) {
|
|
let url = api_url + `getyml?f=${f}`;
|
|
let promised = fetch(`/${f}`).
|
|
then(resp => resp.text()).
|
|
then(yaml => {
|
|
document.getElementsByName('tx')[0].value = yaml;
|
|
return yaml;
|
|
}).
|
|
catch(console.error);
|
|
}
|
|
|
|
// ----------------------------------------------------
|
|
|
|
|
|
console.log('transaction.js loaded');
|