From 493462a31841ac1db699ca67eb562e8508b6fe24 Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Tue, 16 Feb 2021 13:29:29 +0100 Subject: [PATCH] Verify Voucher locks in VoucherValidUnlocked Signed-off-by: Jakub Sztandera --- paychmgr/paych.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/paychmgr/paych.go b/paychmgr/paych.go index c4ef3deb01a..cc793517e3a 100644 --- a/paychmgr/paych.go +++ b/paychmgr/paych.go @@ -180,6 +180,20 @@ func (ca *channelAccessor) checkVoucherValidUnlocked(ctx context.Context, ch add return nil, xerrors.Errorf("voucher ChannelAddr doesn't match channel address, got %s, expected %s", sv.ChannelAddr, ch) } + // check voucher is unlocked + if sv.Extra != nil { + return nil, xerrors.Errorf("voucher is Message Locked") + } + if sv.TimeLockMax != 0 { + return nil, xerrors.Errorf("voucher is Max Time Locked") + } + if sv.TimeLockMin != 0 { + return nil, xerrors.Errorf("voucher is Min Time Locked") + } + if len(sv.SecretPreimage) != 0 { + return nil, xerrors.Errorf("voucher is Hash Locked") + } + // Load payment channel actor state act, pchState, err := ca.sa.loadPaychActorState(ctx, ch) if err != nil {