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
}
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 .