Skip to content

-26: bad-witness-nonstandard #1

@aravinddojima

Description

@aravinddojima
func (tool *InscriptionTool) signCommitTx() error {
	if len(tool.commitTxPrivateKeyList) == 0 {
		commitSignTransaction, isSignComplete, err := tool.client.rpcClient.SignRawTransactionWithWallet(tool.CommitTx)
		if err != nil {
			log.Printf("sign commit tx error, %v", err)
			return err
		}
		if !isSignComplete {
			return errors.New("sign commit tx error")
		}
		tool.CommitTx = commitSignTransaction
	} else {
		witnessList := make([]wire.TxWitness, len(tool.CommitTx.TxIn))
		for i := range tool.CommitTx.TxIn {
			txOut := tool.commitTxPrevOutputFetcher.FetchPrevOutput(tool.CommitTx.TxIn[i].PreviousOutPoint)

			witness, err := txscript.TaprootWitnessSignature(tool.CommitTx, txscript.NewTxSigHashes(tool.CommitTx, tool.commitTxPrevOutputFetcher),
				i, txOut.Value, txOut.PkScript, txscript.SigHashDefault, tool.commitTxPrivateKeyList[i])
			if err != nil {
				return err
			}
			witnessList[i] = witness
		}
		fmt.Println("I am here")
		for i := range witnessList {
			tool.CommitTx.TxIn[i].Witness = witnessList[i]
		}
	}
	return nil
}

txscript.TaprootWitnessSignature(tool.CommitTx, txscript.NewTxSigHashes(tool.CommitTx, tool.commitTxPrevOutputFetcher),

Incorrect witness is produced by TaprootWitnessSignature function. Got (-26: bad-witness-nonstandard) this error when signing using privatekeylist. But it was working fine when it was signed using SignRawTransactionWithWallet .

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions