Skip to content

Commit

Permalink
Verify Voucher locks in VoucherValidUnlocked
Browse files Browse the repository at this point in the history
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
  • Loading branch information
Jakub Sztandera committed Feb 16, 2021
1 parent 6e14bd8 commit 493462a
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions paychmgr/paych.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 493462a

Please sign in to comment.