// Create a new transaction tx := btcutil.NewTx(&wire.MsgTx{ Version: 1, TxIn: []*wire.TxIn{}, TxOut: []*wire.TxOut{}, LockTime: 0, })
// Sign the transaction with a private key sigScript, err := txscript.SignatureScript( tx.TxIn[0].SignatureScript, txscript.NewTxSigHashes(tx), 0, pubKey, txscript.SigHashAll, privKey, true, )In this example, we use the `txscript.SignatureScript` function to sign a transaction using a private key. We pass in the transaction input's existing signature script, a set of transaction signature hashes, the public key, signature hash type, private key, and a flag indicating whether to include the witness script when signing. The function returns the new signature script for the transaction input.