Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions cmd/booster-http/gateway_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,17 @@ func (h *gatewayHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
return
}

// delta is the change in the channel balance caused by adding this voucher.
_, delta := h.nitroRpcClient.ReceiveVoucher(v)
s, err := h.nitroRpcClient.ReceiveVoucher(v)

// TODO: A nil value indicates an error with the voucher. We should update to the latest go-nitro which properly returns the error.
if delta == nil {
webError(w, fmt.Errorf("invalid voucher received %+v", v), http.StatusBadRequest)
if err != nil {
webError(w, fmt.Errorf("error processing voucher %w", err), http.StatusBadRequest)
return
}

// If the voucher resulted in a payment less than the expected payment, return an error.
if delta.Cmp(big.NewInt(expectedPayment)) < 0 {
webError(w, fmt.Errorf("payment of %d required, the voucher only resulted in a payment of %d", expectedPayment, delta.Uint64()), http.StatusPaymentRequired)
// s.Delta is amount our balance increases by adding this voucher
// AKA the payment amount we received in the request for this file
if s.Delta.Cmp(big.NewInt(expectedPayment)) < 0 {
webError(w, fmt.Errorf("payment of %d required, the voucher only resulted in a payment of %d", expectedPayment, s.Delta.Uint64()), http.StatusPaymentRequired)
return
}
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ require (
github.com/ipfs/boxo v0.10.1
github.com/ipfs/kubo v0.21.0-rc1
github.com/ipni/go-libipni v0.0.8
github.com/statechannels/go-nitro v0.0.0-20230705221739-f11101193ac4
github.com/statechannels/go-nitro v0.0.0-20230710223658-280d0225a9d8
)

require (
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1846,8 +1846,8 @@ github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnIn
github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s=
github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE=
github.com/src-d/envconfig v1.0.0/go.mod h1:Q9YQZ7BKITldTBnoxsE5gOeB5y66RyPXeue/R4aaNBc=
github.com/statechannels/go-nitro v0.0.0-20230705221739-f11101193ac4 h1:4lFtN2eJT7Gs0ouEDTZi9vDbU2T5MoQm0wcYP9IIDeQ=
github.com/statechannels/go-nitro v0.0.0-20230705221739-f11101193ac4/go.mod h1:jOuma3zrgCVSByahmABHL733LykH8XFqcRv7Ra1ucvM=
github.com/statechannels/go-nitro v0.0.0-20230710223658-280d0225a9d8 h1:XvtnSc99gOVH5Cd5b4OKU0Zx+YdA7am1QmZPCNkXZNw=
github.com/statechannels/go-nitro v0.0.0-20230710223658-280d0225a9d8/go.mod h1:h2DTAAg1B2CgyL4y3YWIHwcLQk0ZqMHzOCfUXLBURTI=
github.com/status-im/keycard-go v0.2.0 h1:QDLFswOQu1r5jsycloeQh3bVU8n/NatHHaZobtDnDzA=
github.com/status-im/keycard-go v0.2.0/go.mod h1:wlp8ZLbsmrF6g6WjugPAx+IzoLrkdf9+mHxBEeo3Hbg=
github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw=
Expand Down