You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
1.0 KiB

  1. package test
  2. import (
  3. "bytes"
  4. "context"
  5. "github.com/btcsuite/btcd/wire"
  6. "github.com/lightningnetwork/lnd/input"
  7. "github.com/lightningnetwork/lnd/keychain"
  8. )
  9. type mockSigner struct {
  10. lnd *LndMockServices
  11. }
  12. func (s *mockSigner) SignOutputRaw(ctx context.Context, tx *wire.MsgTx,
  13. signDescriptors []*input.SignDescriptor) ([][]byte, error) {
  14. s.lnd.SignOutputRawChannel <- SignOutputRawRequest{
  15. Tx: tx,
  16. SignDescriptors: signDescriptors,
  17. }
  18. rawSigs := [][]byte{{1, 2, 3}}
  19. return rawSigs, nil
  20. }
  21. func (s *mockSigner) SignMessage(ctx context.Context, msg []byte,
  22. locator keychain.KeyLocator) ([]byte, error) {
  23. return s.lnd.Signature, nil
  24. }
  25. func (s *mockSigner) VerifyMessage(ctx context.Context, msg, sig []byte,
  26. pubkey [33]byte) (bool, error) {
  27. // Make the mock somewhat functional by asserting that the message and
  28. // signature is what we expect from the mock parameters.
  29. mockAssertion := bytes.Equal(msg, []byte(s.lnd.SignatureMsg)) &&
  30. bytes.Equal(sig, s.lnd.Signature)
  31. return mockAssertion, nil
  32. }