unisat-wallet / dev-support

35 stars 18 forks source link

How can I indicate an input in PSBT by using inscription info? #9

Open 0xVolar opened 7 months ago

0xVolar commented 7 months ago

I want to create a PSBT by using inscription's info.I know how to create a simple PSBT.It requires a input by using txID.And I find inscription has the id too.Is this id same to txID? Or I need to fill in some other information as input?I have no idea with that.

abangZ commented 7 months ago

The inscriptions are contained within the inputs of a reveal transaction. In order to uniquely identify them they are assigned an ID of the form:

521f8eccffa4c41a3a7728dd012ea5a4a02feed81f41159231251ecf1e5c79dai0

The part in front of the i is the transaction ID (txid) of the reveal transaction. The number after the i defines the index (starting at 0) of new inscriptions being inscribed in the reveal transaction.

here is the document link: https://docs.ordinals.com/inscriptions.html

abangZ commented 7 months ago

https://docs.unisat.io/dev/unisat-developer-service/general/inscriptions/get-inscription-info

this api can get the inscription detail.

0xVolar commented 7 months ago

So,I can use this apihttps://docs.unisat.io/dev/unisat-developer-service/general/addresses/get-inscription-utxoto get the utxo as the input of PSBT?

abangZ commented 7 months ago

So,I can use this apihttps://docs.unisat.io/dev/unisat-developer-service/general/addresses/get-inscription-utxoto get the utxo as the input of PSBT?

yes

0xVolar commented 7 months ago

What should I do if I have A signed PSBT A and I want to use the signed input in A as the input for PSBT in the new PSBT B?

const tx = psbtA.extractTransaction();

psbtB.addInput({
        hash: tx.ins[0].hash,
        index: tx.ins[0].index,
    });

and I get this "Can't find pubkey in input without Utxo data" when I use signPsbt. What can I do to solve this question?

0xVolar commented 7 months ago

If I include both inscriptions and btc in a PSBT, then there is a risk when signing PSBT, so how do I solve this problem and distinguish between inscriptions and btc?

xhyhh0 commented 5 months ago

What should I do if I have A signed PSBT A and I want to use the signed input in A as the input for PSBT in the new PSBT B?

const tx = psbtA.extractTransaction();

psbtB.addInput({
        hash: tx.ins[0].hash,
        index: tx.ins[0].index,
    });

and I get this "Can't find pubkey in input without Utxo data" when I use signPsbt. What can I do to solve this question?

I think you are intending to use the output of transaction A as the input for transaction B. In that case, you should do it like this: const txid = tx.getId(); The hash is the txid, and vout is the number of the output you want to reference.