signer.go 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. package input
  2. import (
  3. "github.com/btcsuite/btcd/wire"
  4. )
  5. // Signer represents an abstract object capable of generating raw signatures as
  6. // well as full complete input scripts given a valid SignDescriptor and
  7. // transaction. This interface fully abstracts away signing paving the way for
  8. // Signer implementations such as hardware wallets, hardware tokens, HSM's, or
  9. // simply a regular wallet.
  10. type Signer interface {
  11. // MuSig2Signer is an embedded interface to make sure all our signers
  12. // also support MuSig2 signing, so we can forward calls to a remote
  13. // signer as well.
  14. MuSig2Signer
  15. // SignOutputRaw generates a signature for the passed transaction
  16. // according to the data within the passed SignDescriptor.
  17. //
  18. // NOTE: The resulting signature should be void of a sighash byte.
  19. SignOutputRaw(tx *wire.MsgTx, signDesc *SignDescriptor) (Signature,
  20. error)
  21. // ComputeInputScript generates a complete InputIndex for the passed
  22. // transaction with the signature as defined within the passed
  23. // SignDescriptor. This method should be capable of generating the
  24. // proper input script for both regular p2wkh/p2tr outputs and p2wkh
  25. // outputs nested within a regular p2sh output.
  26. //
  27. // NOTE: This method will ignore any tweak parameters set within the
  28. // passed SignDescriptor as it assumes a set of typical script
  29. // templates (p2wkh, p2tr, np2wkh, etc).
  30. ComputeInputScript(tx *wire.MsgTx, signDesc *SignDescriptor) (*Script,
  31. error)
  32. }
  33. // Script represents any script inputs required to redeem a previous
  34. // output. This struct is used rather than just a witness, or scripSig in order
  35. // to accommodate nested p2sh which utilizes both types of input scripts.
  36. type Script struct {
  37. // Witness is the full witness stack required to unlock this output.
  38. Witness wire.TxWitness
  39. // SigScript will only be populated if this is an input script sweeping
  40. // a nested p2sh output.
  41. SigScript []byte
  42. }