diff --git a/test/lnd_services_mock.go b/test/lnd_services_mock.go index 07e25170..aaf5c110 100644 --- a/test/lnd_services_mock.go +++ b/test/lnd_services_mock.go @@ -129,6 +129,11 @@ type SignOutputRawRequest struct { SignDescriptors []*lndclient.SignDescriptor } +// PublishHandler is optional transaction handler function called upon calling +// the method PublishTransaction. +type PublishHandler func(ctx context.Context, tx *wire.MsgTx, + label string) error + // LndMockServices provides a full set of mocked lnd services. type LndMockServices struct { lndclient.LndServices @@ -174,6 +179,8 @@ type LndMockServices struct { WaitForFinished func() + PublishHandler PublishHandler + lock sync.Mutex } diff --git a/test/walletkit_mock.go b/test/walletkit_mock.go index 4229e964..70a9f2f4 100644 --- a/test/walletkit_mock.go +++ b/test/walletkit_mock.go @@ -113,7 +113,13 @@ func (m *mockWalletKit) NextAddr(context.Context, string, walletrpc.AddressType, } func (m *mockWalletKit) PublishTransaction(ctx context.Context, tx *wire.MsgTx, - _ string) error { + label string) error { + + if m.lnd.PublishHandler != nil { + if err := m.lnd.PublishHandler(ctx, tx, label); err != nil { + return err + } + } m.lnd.AddTx(tx) m.lnd.TxPublishChannel <- tx