Skip to content
This repository was archived by the owner on Mar 28, 2023. It is now read-only.

Commit bf685d8

Browse files
authored
Merge pull request #2020 from OpenBazaar/notiffix
(#1943) Fix currency value in order notification
2 parents 1c9222c + 5d059a3 commit bf685d8

File tree

2 files changed

+2
-28
lines changed

2 files changed

+2
-28
lines changed

repo/listing.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -919,8 +919,8 @@ func (cs ListingCoupons) GetProtobuf() []*pb.Listing_Coupon {
919919
var cspb = make([]*pb.Listing_Coupon, len(cs))
920920
for i, c := range cs {
921921
cspb[i] = &pb.Listing_Coupon{
922-
Title: c.GetTitle(),
923-
PercentDiscount: c.GetPercentOff(),
922+
Title: c.GetTitle(),
923+
PercentDiscount: c.GetPercentOff(),
924924
}
925925
if c.GetAmountOff() != nil {
926926
cspb[i].BigPriceDiscount = c.GetAmountOff().Amount.String()

wallet/listeners/transaction_listener.go

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package bitcoin
22

33
import (
4-
"math"
54
"math/big"
65
"sync"
76
"time"
@@ -225,19 +224,6 @@ func (l *TransactionListener) processSalePayment(txid string, output wallet.Tran
225224
return
226225
}
227226

228-
// update divisibility from contract listing
229-
if contract.VendorListings[0].Metadata.ContractType != pb.Listing_Metadata_CRYPTOCURRENCY {
230-
customDivisibility := currencyDivisibilityFromContract(l.multiwallet, contract)
231-
if customDivisibility != currencyValue.Currency.Divisibility {
232-
currencyValue.Currency.Divisibility = customDivisibility
233-
if err := currencyValue.Valid(); err != nil {
234-
log.Errorf("Invalid currency divisibility (%d) found in contract (%s): %s", customDivisibility, orderId, err.Error())
235-
return
236-
}
237-
}
238-
}
239-
240-
// TODO: this comparison needs to consider the possibility of different divisibilities
241227
if funding.Cmp(currencyValue.Amount) >= 0 {
242228
log.Debugf("Received payment for order %s", orderId)
243229
funded = true
@@ -311,18 +297,6 @@ func (l *TransactionListener) processSalePayment(txid string, output wallet.Tran
311297
}
312298
}
313299

314-
func currencyDivisibilityFromContract(mw multiwallet.MultiWallet, contract *pb.RicardianContract) uint {
315-
var currencyDivisibility = contract.VendorListings[0].Item.PriceCurrency.Divisibility
316-
if currencyDivisibility != 0 {
317-
return uint(currencyDivisibility)
318-
}
319-
wallet, err := mw.WalletForCurrencyCode(contract.BuyerOrder.Payment.AmountCurrency.Code)
320-
if err == nil {
321-
return uint(math.Log10(float64(wallet.ExchangeRates().UnitsPerCoin())))
322-
}
323-
return core.DefaultCurrencyDivisibility
324-
}
325-
326300
func (l *TransactionListener) processPurchasePayment(txid string, output wallet.TransactionOutput, contract *pb.RicardianContract, state pb.OrderState, funded bool, records []*wallet.TransactionRecord) {
327301
funding := output.Value
328302
for _, r := range records {

0 commit comments

Comments
 (0)