From 4a3c2730727e4b9e439ea195d0cd32eb0f5a4504 Mon Sep 17 00:00:00 2001 From: Dirk McCormick Date: Wed, 19 Aug 2020 18:56:51 -0400 Subject: [PATCH] fix: paych - check wallet for key for channel To address --- paychmgr/manager.go | 7 ++++++- paychmgr/mock_test.go | 4 ++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/paychmgr/manager.go b/paychmgr/manager.go index db685bbbf..fe41100ae 100644 --- a/paychmgr/manager.go +++ b/paychmgr/manager.go @@ -45,6 +45,7 @@ type stateManagerAPI interface { // paychAPI defines the API methods needed by the payment channel manager type paychAPI interface { + StateAccountKey(context.Context, address.Address, types.TipSetKey) (address.Address, error) StateWaitMsg(ctx context.Context, msg cid.Cid, confidence uint64) (*api.MsgLookup, error) MpoolPushMessage(ctx context.Context, msg *types.Message, maxFee *api.MessageSendSpec) (*types.SignedMessage, error) WalletHas(ctx context.Context, addr address.Address) (bool, error) @@ -256,7 +257,11 @@ func (pm *Manager) trackInboundChannel(ctx context.Context, ch address.Address) // Check that channel To address is in wallet to := stateCi.Control // Inbound channel so To addr is Control (this node) - has, err := pm.pchapi.WalletHas(ctx, to) + toKey, err := pm.pchapi.StateAccountKey(ctx, to, types.EmptyTSK) + if err != nil { + return nil, err + } + has, err := pm.pchapi.WalletHas(ctx, toKey) if err != nil { return nil, err } diff --git a/paychmgr/mock_test.go b/paychmgr/mock_test.go index 26b47976a..1c8674ae4 100644 --- a/paychmgr/mock_test.go +++ b/paychmgr/mock_test.go @@ -202,6 +202,10 @@ func (pchapi *mockPaychAPI) pushedMessageCount() int { return len(pchapi.messages) } +func (pchapi *mockPaychAPI) StateAccountKey(ctx context.Context, addr address.Address, tsk types.TipSetKey) (address.Address, error) { + return addr, nil +} + func (pchapi *mockPaychAPI) WalletHas(ctx context.Context, addr address.Address) (bool, error) { pchapi.lk.Lock() defer pchapi.lk.Unlock()