me-foundation/msigner

What are the 2 new dummy outputs created for?

Opened this issue ยท 3 comments

Firstly, thanks for putting this together!

I'm just a little confused about what the 2 new dummy outputs created are for. I see the code says:
https://github.com/magiceden-oss/msigner/blob/3de81d4aaac4d030b2fb2967d704a59070981777/src/signer.ts#L465

Is it to avoid having to create a new tx with 2 dummy inputs in a future purchase? Also, do they have any specific values?

Yes, they're used for future purchase, so that people don't need to prepare the dummy utxos again

i don't understand the need for the 2 dummy utxos, can you point me to any materials where i can learn?

casey commented

I was curious about why this library uses two dummy inputs as well. I think it's because if you only use one dummy input, the ordinal winds up being unaligned. Let's say we use one dummy and have a final transaction with inputs valued A, A, and B, and outputs valued 2 A and B, with the ordinal being sold on the first sat of the second A input:

A    2A
A -> B
B

The transaction value balances, however the ordinal will wind up in the middle of the first output.

If, on the other hand, we add an additional dummy:

A    2A
A    A
A -> B
B

Then the ordinals winds up on the first sat of the second output.

And two dummy outputs are used because that's the number of dummy inputs required.