@@ -1621,14 +1621,22 @@ func (i *jsonAPIHandler) POSTOrderConfirmation(w http.ResponseWriter, r *http.Re
1621
1621
ErrorResponse (w , http .StatusBadRequest , err .Error ())
1622
1622
return
1623
1623
}
1624
+
1625
+ order , err := i .node .GetOrder (conf .OrderID )
1626
+ if err != nil {
1627
+ ErrorResponse (w , http .StatusInternalServerError , err .Error ())
1628
+ return
1629
+ }
1630
+ v5contract := order .Contract
1631
+
1624
1632
contract , state , funded , records , _ , _ , err := i .node .Datastore .Sales ().GetByOrderId (conf .OrderID )
1625
1633
if err != nil {
1626
1634
ErrorResponse (w , http .StatusNotFound , err .Error ())
1627
1635
return
1628
1636
}
1629
1637
1630
1638
// TODO: Remove once broken contracts are migrated
1631
- lookupCoin := contract .BuyerOrder .Payment .AmountCurrency .Code
1639
+ lookupCoin := v5contract .BuyerOrder .Payment .AmountCurrency .Code
1632
1640
_ , err = i .node .LookupCurrency (lookupCoin )
1633
1641
if err != nil {
1634
1642
log .Warningf ("invalid BuyerOrder.Payment.Coin (%s) on order (%s)" , lookupCoin , conf .OrderID )
@@ -1776,7 +1784,7 @@ func (i *jsonAPIHandler) POSTRefund(w http.ResponseWriter, r *http.Request) {
1776
1784
ErrorResponse (w , http .StatusBadRequest , err .Error ())
1777
1785
return
1778
1786
}
1779
- contract , state , _ , records , _ , _ , err := i .node .Datastore .Sales ().GetByOrderId (can .OrderID )
1787
+ _ , state , _ , records , _ , _ , err := i .node .Datastore .Sales ().GetByOrderId (can .OrderID )
1780
1788
if err != nil {
1781
1789
ErrorResponse (w , http .StatusNotFound , "order not found" )
1782
1790
return
@@ -1787,14 +1795,21 @@ func (i *jsonAPIHandler) POSTRefund(w http.ResponseWriter, r *http.Request) {
1787
1795
}
1788
1796
1789
1797
// TODO: Remove once broken contracts are migrated
1790
- lookupCoin := contract .BuyerOrder .Payment .AmountCurrency .Code
1798
+ order , err := i .node .GetOrder (can .OrderID )
1799
+ if err != nil {
1800
+ ErrorResponse (w , http .StatusInternalServerError , err .Error ())
1801
+ return
1802
+ }
1803
+ v5contract := order .Contract
1804
+
1805
+ lookupCoin := v5contract .BuyerOrder .Payment .AmountCurrency .Code
1791
1806
_ , err = i .node .LookupCurrency (lookupCoin )
1792
1807
if err != nil {
1793
1808
log .Warningf ("invalid BuyerOrder.Payment.Coin (%s) on order (%s)" , lookupCoin , can .OrderID )
1794
1809
//contract.BuyerOrder.Payment.Coin = paymentCoin.String()
1795
1810
}
1796
1811
1797
- err = i .node .RefundOrder (contract , records )
1812
+ err = i .node .RefundOrder (v5contract , records )
1798
1813
if err != nil {
1799
1814
ErrorResponse (w , http .StatusInternalServerError , err .Error ())
1800
1815
return
@@ -1980,14 +1995,21 @@ func (i *jsonAPIHandler) POSTOrderFulfill(w http.ResponseWriter, r *http.Request
1980
1995
ErrorResponse (w , http .StatusBadRequest , err .Error ())
1981
1996
return
1982
1997
}
1983
- contract , state , _ , records , _ , _ , err := i .node .Datastore .Sales ().GetByOrderId (fulfill .OrderId )
1998
+ _ , state , _ , records , _ , _ , err := i .node .Datastore .Sales ().GetByOrderId (fulfill .OrderId )
1984
1999
if err != nil {
1985
2000
ErrorResponse (w , http .StatusNotFound , "order not found" )
1986
2001
return
1987
2002
}
1988
2003
1989
2004
// TODO: Remove once broken contracts are migrated
1990
- lookupCoin := contract .BuyerOrder .Payment .AmountCurrency .Code
2005
+ order , err := i .node .GetOrder (fulfill .OrderId )
2006
+ if err != nil {
2007
+ ErrorResponse (w , http .StatusNotFound , "order not found" )
2008
+ return
2009
+ }
2010
+ v5contract := order .Contract
2011
+
2012
+ lookupCoin := v5contract .BuyerOrder .Payment .AmountCurrency .Code
1991
2013
_ , err = i .node .LookupCurrency (lookupCoin )
1992
2014
if err != nil {
1993
2015
log .Warningf ("invalid BuyerOrder.Payment.Coin (%s) on order (%s)" , lookupCoin , fulfill .OrderId )
@@ -1998,7 +2020,7 @@ func (i *jsonAPIHandler) POSTOrderFulfill(w http.ResponseWriter, r *http.Request
1998
2020
ErrorResponse (w , http .StatusBadRequest , "order must be in state AWAITING_FULFILLMENT or PARTIALLY_FULFILLED to fulfill" )
1999
2021
return
2000
2022
}
2001
- err = i .node .FulfillOrder (& fulfill , contract , records )
2023
+ err = i .node .FulfillOrder (& fulfill , v5contract , records )
2002
2024
if err != nil {
2003
2025
ErrorResponse (w , http .StatusInternalServerError , err .Error ())
2004
2026
return
@@ -2211,6 +2233,16 @@ func (i *jsonAPIHandler) GETCase(w http.ResponseWriter, r *http.Request) {
2211
2233
ErrorResponse (w , http .StatusInternalServerError , err .Error ())
2212
2234
return
2213
2235
}
2236
+
2237
+ if buyerContract .BuyerOrder .Payment .BigAmount == "" {
2238
+ v5order , err := repo .ToV5Order (buyerContract .BuyerOrder , nil )
2239
+ if err != nil {
2240
+ ErrorResponse (w , http .StatusInternalServerError , err .Error ())
2241
+ return
2242
+ }
2243
+ buyerContract .BuyerOrder = v5order
2244
+ }
2245
+
2214
2246
resp .BuyerContract = buyerContract
2215
2247
resp .VendorContract = vendorContract
2216
2248
resp .BuyerOpened = buyerOpened
@@ -2326,7 +2358,13 @@ func (i *jsonAPIHandler) POSTReleaseEscrow(w http.ResponseWriter, r *http.Reques
2326
2358
}
2327
2359
2328
2360
// TODO: Remove once broken contracts are migrated
2329
- lookupCoin := contract .BuyerOrder .Payment .AmountCurrency .Code
2361
+ order , err := i .node .GetOrder (rel .OrderID )
2362
+ if err != nil {
2363
+ ErrorResponse (w , http .StatusBadRequest , "Could not retrieve the order" )
2364
+ return
2365
+ }
2366
+
2367
+ lookupCoin := order .Contract .BuyerOrder .Payment .AmountCurrency .Code
2330
2368
_ , err = i .node .LookupCurrency (lookupCoin )
2331
2369
if err != nil {
2332
2370
log .Warningf ("invalid BuyerOrder.Payment.Coin (%s) on order (%s)" , lookupCoin , rel .OrderID )
0 commit comments