fix: paych - clarify behaviour of current available funds for non-existent channel
This commit is contained in:
parent
2c98bf0cc7
commit
3daa0b5e63
@ -301,12 +301,10 @@ func (ca *channelAccessor) msgWaitComplete(mcid cid.Cid, err error) {
|
|||||||
|
|
||||||
func (ca *channelAccessor) currentAvailableFunds(queuedAmt types.BigInt) (*api.ChannelAvailableFunds, error) {
|
func (ca *channelAccessor) currentAvailableFunds(queuedAmt types.BigInt) (*api.ChannelAvailableFunds, error) {
|
||||||
channelInfo, err := ca.store.OutboundActiveByFromTo(ca.from, ca.to)
|
channelInfo, err := ca.store.OutboundActiveByFromTo(ca.from, ca.to)
|
||||||
if err != nil && err != ErrChannelNotTracked {
|
if err == ErrChannelNotTracked {
|
||||||
return nil, err
|
// If the channel does not exist we still want to return an empty
|
||||||
}
|
// ChannelAvailableFunds, so that clients can check for the existence
|
||||||
|
// of a channel between from / to without getting an error.
|
||||||
if channelInfo == nil {
|
|
||||||
// Channel does not exist
|
|
||||||
return &api.ChannelAvailableFunds{
|
return &api.ChannelAvailableFunds{
|
||||||
Channel: nil,
|
Channel: nil,
|
||||||
ConfirmedAmt: types.NewInt(0),
|
ConfirmedAmt: types.NewInt(0),
|
||||||
@ -316,6 +314,9 @@ func (ca *channelAccessor) currentAvailableFunds(queuedAmt types.BigInt) (*api.C
|
|||||||
VoucherReedeemedAmt: types.NewInt(0),
|
VoucherReedeemedAmt: types.NewInt(0),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
// The channel may have a pending create or add funds message
|
// The channel may have a pending create or add funds message
|
||||||
waitSentinel := channelInfo.CreateMsg
|
waitSentinel := channelInfo.CreateMsg
|
||||||
|
Loading…
Reference in New Issue
Block a user