Skip to content

Error: No signatures for this pubkey #1

@chironjit-neoswap

Description

@chironjit-neoswap

Hi, i am trying to sign a psbt for an ordinal but i keep getting this error:

PSBT generator:

async function generatePSBTForSale(ordinalUtxoTxId, ordinalUtxoVout, price, paymentAddress) {
    let psbt = new bitcoin.Psbt({ network });

    const tx = bitcoin.Transaction.fromHex(await getTxHexById(ordinalUtxoTxId))
    for (const output in tx.outs) {
        try { tx.setWitness(parseInt(output), []) } catch { }
    }

    const input = {
        hash: ordinalUtxoTxId,
        index: parseInt(ordinalUtxoVout),
        nonWitnessUtxo: tx.toBuffer(),
        witnessUtxo: tx.outs[ordinalUtxoVout],
        sighashType: bitcoin.Transaction.SIGHASH_SINGLE | bitcoin.Transaction.SIGHASH_ANYONECANPAY,
    }

    psbt.addInput(input);

    psbt.addOutput({
        address: paymentAddress,
        value: price,
    });

    return psbt.toBase64();
}

const formattedPsbt = await generatePSBTForSale("7c60d897c2637c1d811eec393f3c2c5d120cf9bb5502ad17e76c96acdd961a89", 0, 10000, segwitAddress1)

PSBT formatting and signing:

const wallet = new Wallet(key1, NetworkType.MAINNET, AddressType.P2TR);
const bufferPsbt = Buffer.from(formattedPsbt, 'base64')
const hexpsbt = bufferPsbt.toString('hex')

const signedPsbtHex = await wallet.signPsbt(hexpsbt, [
    {
      index: 0,
      publicKey: await wallet.getPublicKey(),
      sighashTypes: [
        bitcoin.Transaction.SIGHASH_SINGLE | bitcoin.Transaction.SIGHASH_ANYONECANPAY,
      ],
    },
  ]);

I however get this error when trying to sign:

if (!allHashses.length) throw new Error('No signatures for this pubkey');
                                  ^

Error: No signatures for this pubkey

May i ask if this an issue with my formatting or is this an issue with the local wallet?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions