invoice: avoid negative msat amounts

This commit is contained in:
Wilmer Paulino committed 2018-01-23 14:38:20 -05:00
1 parent dd08662c87
commit cfb19b8d51
3 files changed
+17

No files matched your search

+4
View File
@@ -127,6 +127,10 @@ func decodeAmount(amount string) (lnwire.MilliSatoshi, error) {
// encodeAmount encodes the provided millisatoshi amount using as few characters
// as possible.
func encodeAmount(msat lnwire.MilliSatoshi) (string, error) {
if msat < 0 {
return "", fmt.Errorf("amount must be positive: %v", msat)
}
// If possible to express in BTC, that will always be the shortest
// representation.
if msat%mSatPerBtc == 0 {