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

Commit 07dcb83

Browse files
committed
Fix conversion nits
1 parent 9dd395a commit 07dcb83

File tree

5 files changed

+10
-9
lines changed

5 files changed

+10
-9
lines changed

core/confirmation.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ func (n *OpenBazaarNode) NewOrderConfirmation(contract *pb.RicardianContract, ad
8888
oc.PaymentAddress = order.Payment.Address
8989
}
9090

91-
oc.BigRequestedAmount = big.NewInt(int64(order.Payment.Amount)).String()
91+
oc.BigRequestedAmount = order.Payment.BigAmount
9292
contract.VendorOrderConfirmation = oc
9393
contract, err = n.SignOrderConfirmation(contract)
9494
if err != nil {

core/disputes.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ func (n *OpenBazaarNode) ProcessDisputeOpen(rc *pb.RicardianContract, peerID str
282282
if len(contract.VendorListings) > 0 && contract.VendorListings[0].Item != nil && len(contract.VendorListings[0].Item.Images) > 0 {
283283
thumbnailTiny = contract.VendorListings[0].Item.Images[0].Tiny
284284
thumbnailSmall = contract.VendorListings[0].Item.Images[0].Small
285-
if order != nil && order.BuyerID != nil {
285+
if order.BuyerID != nil {
286286
buyer = order.BuyerID.PeerID
287287
}
288288
}
@@ -643,7 +643,7 @@ func (n *OpenBazaarNode) CloseDispute(orderID string, buyerPercentage, vendorPer
643643

644644
// Calculate total fee
645645
defaultFee := wal.GetFeePerByte(wallet.NORMAL)
646-
txFee := wal.EstimateFee(inputs, outputs, dispute.ResolutionPaymentFeePerByte(payDivision, defaultFee))
646+
txFee := wal.EstimateFee(inputs, outputs, *dispute.ResolutionPaymentFeePerByte(payDivision, defaultFee))
647647

648648
// Subtract fee from each output in proportion to output value
649649
var outs []wallet.TransactionOutput
@@ -916,6 +916,7 @@ func (n *OpenBazaarNode) ValidateCaseContract(contract *pb.RicardianContract) []
916916
if contract.BuyerOrder.Payment != nil {
917917
order, err := repo.ToV5Order(contract.BuyerOrder, n.LookupCurrency)
918918
if err != nil {
919+
validationErrors = append(validationErrors, fmt.Sprintf("Error converting to v5 order: %s", err))
919920
return validationErrors
920921
}
921922
wal, err := n.Multiwallet.WalletForCurrencyCode(order.Payment.AmountCurrency.Code)

core/utils.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func (n *OpenBazaarNode) BuildTransactionRecords(contract *pb.RicardianContract,
7171
paymentRecords = append(paymentRecords, rec)
7272
}
7373
var refundRecord *pb.TransactionRecord
74-
if contract != nil && (state == pb.OrderState_REFUNDED || state == pb.OrderState_DECLINED || state == pb.OrderState_CANCELED) && order != nil && order.Payment != nil {
74+
if contract != nil && (state == pb.OrderState_REFUNDED || state == pb.OrderState_DECLINED || state == pb.OrderState_CANCELED) && order.Payment != nil {
7575
// For multisig we can use the outgoing from the payment address
7676
if order.Payment.Method == pb.Order_Payment_MODERATED || state == pb.OrderState_DECLINED || state == pb.OrderState_CANCELED {
7777
for _, rec := range payments {

net/service/handlers.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1156,7 +1156,7 @@ func (service *OpenBazaarService) handleOrderCompletion(p peer.ID, pmes *pb.Mess
11561156
if len(contract.VendorListings) > 0 && contract.VendorListings[0].Item != nil && len(contract.VendorListings[0].Item.Images) > 0 {
11571157
thumbnailTiny = contract.VendorListings[0].Item.Images[0].Tiny
11581158
thumbnailSmall = contract.VendorListings[0].Item.Images[0].Small
1159-
if order != nil && order.BuyerID != nil {
1159+
if order.BuyerID != nil {
11601160
buyerID = order.BuyerID.PeerID
11611161
buyerHandle = order.BuyerID.Handle
11621162
}

repo/dispute_case_record.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,20 +103,20 @@ func (r *DisputeCaseRecord) Contract() *pb.RicardianContract {
103103

104104
// ResolutionPaymentFeePerByte returns the preferred outpoints to be used when resolving
105105
// a pending DisputeCaseResolution based on the provided PayoutRatio
106-
func (r *DisputeCaseRecord) ResolutionPaymentFeePerByte(ratio PayoutRatio, defaultFee big.Int) big.Int {
106+
func (r *DisputeCaseRecord) ResolutionPaymentFeePerByte(ratio PayoutRatio, defaultFee big.Int) *big.Int {
107107
n := new(big.Int)
108108
switch {
109109
case ratio.BuyerMajority(), ratio.EvenMajority():
110110
n, _ = n.SetString(r.BuyerContract.BuyerOrder.BigRefundFee, 10)
111-
return *n
111+
return n
112112
case ratio.VendorMajority():
113113
if len(r.VendorContract.VendorOrderFulfillment) > 0 && r.VendorContract.VendorOrderFulfillment[0].Payout != nil {
114114
fulfillment := ToV5OrderFulfillment(r.VendorContract.VendorOrderFulfillment[0])
115115
n, _ = n.SetString(fulfillment.Payout.BigPayoutFeePerByte, 10)
116-
return *n
116+
return n
117117
}
118118
}
119-
return *n
119+
return n
120120
}
121121

122122
// ResolutionPaymentOutpoints returns the preferred outpoints to be used when resolving

0 commit comments

Comments
 (0)