From b5d9d8aa9c6a26b8fc0eb6c25b8c8cfafbe55270 Mon Sep 17 00:00:00 2001 From: Markus Bopp Date: Fri, 24 Mar 2023 04:01:29 +0100 Subject: [PATCH] # fixed vouts for inscription transactions --- signet.html | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/signet.html b/signet.html index de85a35..f3c4804 100644 --- a/signet.html +++ b/signet.html @@ -266,6 +266,7 @@ showUploader(); + let pushing = false; let files = []; $( '.form' ).addEventListener( "change", async function() { @@ -368,8 +369,6 @@ console.log('Inscription address: ', inscriptionAddress ); console.log('Tapkey:', tapkey); - // total_costs_sats = amount_inscriptions * ( 10k + ( ( ( file_kb * 1000 ) / 4 ) * fee_rate ) ) - var txsize = 500 + Math.floor(data.length / 4); var feerate = await getMinFeeRate(); @@ -465,7 +464,7 @@ // seeder received everything, now it is time to populate the others - async function inscribe(inscription) + async function inscribe(inscription, vout) { await loopTilAddressReceivesMoney( inscription.inscriptionAddress, false ); @@ -480,7 +479,7 @@ version: 2, input: [{ txid: txid2, - vout: vout2, + vout: vout, prevout: { value: amt2, scriptPubKey: '5120' + inscription.tapkey }, witness: [] }], @@ -497,7 +496,13 @@ console.dir(redeemtx, { depth: null }); var rawtx2 = BTON.Tx.encode(redeemtx); + + // since we don't know any mempool space api rate limits, we will be careful with spamming + await isPushing(); + pushing = true; var _txid2 = await pushBTCpmt( rawtx2 ); + await sleep(1000); + pushing = false; var html = `

Success! Your file will shortly be inscribed on the bitcoin blockchain in this transaction:

https://mempool.space/signet/tx/${_txid2}

`; html += `

When your transaction confirms you can view it on the ordinals explorer here:

https://ordinals.com/inscription/${_txid2}i0

`; @@ -510,10 +515,23 @@ for(let i = 0; i < inscriptions.length; i++) { - inscribe(inscriptions[i]); + inscribe(inscriptions[i], i); } }); + async function isPushing() + { + while(pushing) + { + await sleep(10); + } + } + + function sleep(ms) { + + return new Promise(resolve => setTimeout(resolve, ms)); + } + async function getMaxFeeRate() { var fees = await getData( "https://mempool.space/signet/api/v1/fees/recommended" ); fees = JSON.parse( fees );