From a7fbc8590ba2d03963045d197ed832771c66d7d8 Mon Sep 17 00:00:00 2001 From: Chris Sexton Date: Thu, 18 Jul 2019 14:57:24 -0400 Subject: [PATCH] bid: disallow negative bids --- plugins/newsbid/webshit/webshit.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugins/newsbid/webshit/webshit.go b/plugins/newsbid/webshit/webshit.go index dead1ae..4b1012f 100644 --- a/plugins/newsbid/webshit/webshit.go +++ b/plugins/newsbid/webshit/webshit.go @@ -280,6 +280,9 @@ func (w *Webshit) GetAllBalances() ([]Balance, error) { // Bid allows a user to place a bid on a particular story func (w *Webshit) Bid(user string, amount int, URL string) (Bid, error) { bal := w.GetBalance(user) + if amount < 0 { + return Bid{}, fmt.Errorf("cannot bid less than 0") + } if bal < amount { return Bid{}, fmt.Errorf("cannot bid more than balance, %d", bal) }