cmdruid / tapscript

A humble library for working with Tapscript and Bitcoin Transactions.
https://www.npmjs.com/package/@cmdcode/tapscript
Creative Commons Zero v1.0 Universal
188 stars 49 forks source link

Question: Order of inputs in a transaction. #45

Closed maxgmer closed 1 month ago

maxgmer commented 1 month ago

The way address spending works is:

  1. First inputs' sats cover the output amount.
  2. Remaining inputs' sats, which didn't fit into the output amount, go to miners.

But how do I specify the order of input UTXOs with this library? I want to make sure inscription UTXOs are first, while ordinary sats are last, so that inscriptions don't leak to miners.

cmdruid commented 1 month ago

When you create a TxData object, the vin and vout are arrays, and the order of items in that array is the order in which they will be encoded when you convert the transaction data into hex.

maxgmer commented 1 month ago

@cmdruid I see, thanks!