Skip to content
This repository was archived by the owner on Mar 28, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
6556f74
Update test_framework.py to support version compatibility tests
cpacia Oct 16, 2019
afd01e8
Merge branch 'ethereum-master' of https://github.com/OpenBazaar/openb…
cpacia Dec 4, 2019
ee897d6
Update qa tests with data version selection
cpacia Dec 9, 2019
2452072
Fix bugs calling start_node
cpacia Dec 9, 2019
d77e45b
Check for connection reset error
hoffmabc Dec 9, 2019
a6454a2
Update qa tests to parse responses by version
cpacia Dec 20, 2019
41237fb
Merge branch 'compatibilitytest' of https://github.com/OpenBazaar/ope…
cpacia Dec 20, 2019
13d28b1
Rebase to ethereum-master
cpacia Feb 24, 2020
c7f3a87
Fdaf
cpacia Feb 25, 2020
569a972
Merge pull request #2026 from OpenBazaar/ethereum-master
cpacia Mar 9, 2020
a3007d0
Upgrade golangci
hoffmabc Mar 9, 2020
98a9ed1
Remove revision
hoffmabc Mar 9, 2020
707a3f1
golangci lint fixes
hoffmabc Mar 9, 2020
c1e7b23
Merge pull request #2027 from OpenBazaar/brian.fix-traavis
hoffmabc Mar 9, 2020
ab09e71
Added orderConfirmation state check
rodkeys Mar 10, 2020
191eb3c
gofmt file
hoffmabc Mar 10, 2020
728b107
Merge pull request #2028 from rodkeys/master
hoffmabc Mar 10, 2020
f0eb5c3
Fix scientific notation coming out of database for purchases
hoffmabc Mar 10, 2020
3686cd2
Check for nil blocknumber when retrieving tx
hoffmabc Mar 10, 2020
e0d0e10
Ensure the right amount of confs
hoffmabc Mar 10, 2020
fa1114a
Merge pull request #2029 from OpenBazaar/brian.fix-scientificnotation…
cpacia Mar 10, 2020
b8fa58a
Merge pull request #2030 from OpenBazaar/brian.fix2023
cpacia Mar 10, 2020
0b1cd2e
Bump version
hoffmabc Mar 10, 2020
ff8c8f8
Changed func to check if transaction goes through before saving to th…
rodkeys Mar 11, 2020
afdde88
Merge branch 'master' into compatibilitytest
cpacia Mar 11, 2020
ce555f2
Merge pull request #2031 from rodkeys/master
cpacia Mar 11, 2020
35e080e
feat: Endpoint to hash a message
drwasho Mar 12, 2020
467aecf
Merge pull request #2032 from drwasho/drwasho/hashMessage
cpacia Mar 12, 2020
fc67377
Fix: Save DisputeAcceptance to the contract even if state has not pr…
rodkeys Mar 12, 2020
57340cd
Removed the order state requirement for added DisputeAcceptance to th…
rodkeys Mar 12, 2020
6ea019a
Save and load unconfirmed txs from db
cpacia Mar 13, 2020
fb404a2
Merge pull request #2033 from rodkeys/master
hoffmabc Mar 13, 2020
dcf144b
Update eth pending confirmations
cpacia Mar 13, 2020
5da4d62
Fix bugs in compatibility
cpacia Mar 16, 2020
3f25b69
Put eth unconfirmed txs at begining of list return
cpacia Mar 17, 2020
01a24c1
Ignore eth error fetching txs
cpacia Mar 17, 2020
fa5e79b
Fix zero amount on unconfirmed tx
cpacia Mar 17, 2020
aa0fd46
Merge pull request #2034 from OpenBazaar/ethunconf
cpacia Mar 18, 2020
67699a1
Merge branch 'master' into compatibilitytest
cpacia Mar 18, 2020
cffc9c8
Don't set v5 fields when sending v4 contract
cpacia Mar 20, 2020
bd6707c
Update qa tests with v4 fixes
cpacia Mar 23, 2020
39b1230
Fix bug creating v4 moderated order
cpacia Mar 24, 2020
d4f9eb0
Fix fulfill qa test
cpacia Mar 24, 2020
f87525c
Use v4 contract in dispute where needed
cpacia Mar 25, 2020
0a885c5
Fix disputes payouts to v4 vendor
cpacia Mar 26, 2020
0295494
Update escrow release after timeout qa test
cpacia Mar 26, 2020
009285f
Check for correct vendor_version
hoffmabc Mar 24, 2020
9181503
Update cryptolisting qa test
cpacia Apr 2, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ env:
- "PATH=/home/travis/gopath/bin:$PATH"
before_install:
- go get -u github.com/axw/gocov/gocov github.com/mattn/goveralls github.com/tcnksm/ghr
- curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | bash -s -- -b $GOPATH/bin v1.15.0
- curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | bash -s -- -b $GOPATH/bin v1.23.3
install:
- echo "No external dependencies required. Skipping travis default library dependency setup to use vendors..."
script:
- $GOPATH/bin/golangci-lint run --deadline 10m --new-from-rev=24dc0f64
- $GOPATH/bin/golangci-lint run --deadline 10m --new-from-rev=
- cd $TRAVIS_BUILD_DIR && go test -i && ./test_compile.sh
- goveralls -coverprofile=coverage.out -service travis-ci -repotoken $COVERALLS_TOKEN
after_success:
Expand Down
2 changes: 2 additions & 0 deletions api/endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ func post(i *jsonAPIHandler, path string, w http.ResponseWriter, r *http.Request
i.POSTBulkUpdateCurrency(w, r)
case strings.HasPrefix(path, "/ob/resendordermessage"):
i.POSTResendOrderMessage(w, r)
case strings.HasPrefix(path, "/ob/hashmessage"):
i.POSTHashMessage(w, r)
default:
ErrorResponse(w, http.StatusNotFound, "Not Found")
}
Expand Down
59 changes: 54 additions & 5 deletions api/jsonapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -1675,9 +1675,14 @@ func (i *jsonAPIHandler) POSTOrderCancel(w http.ResponseWriter, r *http.Request)
ErrorResponse(w, http.StatusNotFound, "order not found")
return
}
v5order, err := repo.ToV5Order(contract.BuyerOrder, nil)
if err != nil {
ErrorResponse(w, http.StatusNotFound, "order not found")
return
}

// TODO: Remove once broken contracts are migrated
lookupCoin := contract.BuyerOrder.Payment.AmountCurrency.Code
lookupCoin := v5order.Payment.AmountCurrency.Code
_, err = i.node.LookupCurrency(lookupCoin)
if err != nil {
log.Warningf("invalid BuyerOrder.Payment.Coin (%s) on order (%s)", lookupCoin, can.OrderID)
Expand Down Expand Up @@ -2022,8 +2027,14 @@ func (i *jsonAPIHandler) POSTOrderComplete(w http.ResponseWriter, r *http.Reques
return
}

v5order, err := repo.ToV5Order(contract.BuyerOrder, nil)
if err != nil {
ErrorResponse(w, http.StatusNotFound, "order not found")
return
}

// TODO: Remove once broken contracts are migrated
lookupCoin := contract.BuyerOrder.Payment.AmountCurrency.Code
lookupCoin := v5order.Payment.AmountCurrency.Code
_, err = i.node.LookupCurrency(lookupCoin)
if err != nil {
log.Warningf("invalid BuyerOrder.Payment.Coin (%s) on order (%s)", lookupCoin, or.OrderID)
Expand Down Expand Up @@ -2111,7 +2122,13 @@ func (i *jsonAPIHandler) POSTOpenDispute(w http.ResponseWriter, r *http.Request)
}

// TODO: Remove once broken contracts are migrated
lookupCoin := contract.BuyerOrder.Payment.AmountCurrency.Code
v5order, err := repo.ToV5Order(contract.BuyerOrder, nil)
if err != nil {
ErrorResponse(w, http.StatusBadRequest, err.Error())
return
}

lookupCoin := v5order.Payment.AmountCurrency.Code
_, err = i.node.LookupCurrency(lookupCoin)
if err != nil {
log.Warningf("invalid BuyerOrder.Payment.Coin (%s) on order (%s)", lookupCoin, d.OrderID)
Expand Down Expand Up @@ -2257,8 +2274,14 @@ func (i *jsonAPIHandler) POSTReleaseFunds(w http.ResponseWriter, r *http.Request
}
}

v5order, err := repo.ToV5Order(contract.BuyerOrder, nil)
if err != nil {
ErrorResponse(w, http.StatusBadRequest, err.Error())
return
}

// TODO: Remove once broken contracts are migrated
lookupCoin := contract.BuyerOrder.Payment.AmountCurrency.Code
lookupCoin := v5order.Payment.AmountCurrency.Code
_, err = i.node.LookupCurrency(lookupCoin)
if err != nil {
log.Warningf("invalid BuyerOrder.Payment.Coin (%s) on order (%s)", lookupCoin, rel.OrderID)
Expand Down Expand Up @@ -3696,7 +3719,10 @@ func (i *jsonAPIHandler) POSTFetchRatings(w http.ResponseWriter, r *http.Request
id := r.URL.Query().Get("asyncID")
if id == "" {
idBytes := make([]byte, 16)
rand.Read(idBytes)
_, err := rand.Read(idBytes)
if err != nil {
return
}
id = base58.Encode(idBytes)
}

Expand Down Expand Up @@ -4403,3 +4429,26 @@ func (i *jsonAPIHandler) GETScanOfflineMessages(w http.ResponseWriter, r *http.R
}
SanitizedResponse(w, `{}`)
}

func (i *jsonAPIHandler) POSTHashMessage(w http.ResponseWriter, r *http.Request) {
type hashRequest struct {
Content string `json:"content"`
}
var (
req hashRequest
err = json.NewDecoder(r.Body).Decode(&req)
)
if err != nil {
ErrorResponse(w, http.StatusBadRequest, err.Error())
return
}

messageHash, err := ipfs.EncodeMultihash([]byte(req.Content))
if err != nil {
ErrorResponse(w, http.StatusBadRequest, err.Error())
return
}

SanitizedResponse(w, fmt.Sprintf(`{"hash": "%s"}`,
messageHash.B58String()))
}
2 changes: 1 addition & 1 deletion core/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (

const (
// VERSION - current version
VERSION = "0.13.8"
VERSION = "0.14.0"
// USERAGENT - user-agent header string
USERAGENT = "/openbazaar-go:" + VERSION + "/"
)
Expand Down
86 changes: 62 additions & 24 deletions core/disputes.go
Original file line number Diff line number Diff line change
Expand Up @@ -502,12 +502,6 @@ func (n *OpenBazaarNode) CloseDispute(orderID string, buyerPercentage, vendorPer
return ErrCloseFailureCaseExpired
}

var outpoints = dispute.ResolutionPaymentOutpoints(payDivision)
if outpoints == nil {
log.Errorf("no outpoints to resolve in dispute for order %s", orderID)
return ErrCloseFailureNoOutpoints
}

if dispute.VendorContract == nil && vendorPercentage > 0 {
return errors.New("vendor must provide his copy of the contract before you can release funds to the vendor")
}
Expand All @@ -521,6 +515,24 @@ func (n *OpenBazaarNode) CloseDispute(orderID string, buyerPercentage, vendorPer
return err
}

var outpoints = dispute.ResolutionPaymentOutpoints(payDivision)
if outpoints == nil {
log.Errorf("no outpoints to resolve in dispute for order %s", orderID)
return ErrCloseFailureNoOutpoints
}
for i, o := range outpoints {
if preferredContract.VendorListings[0].Metadata.Version < repo.ListingVersion {
if o.BigValue != "" {
n, ok := new(big.Int).SetString(o.BigValue, 10)
if !ok {
return errors.New("invalid amount")
}
outpoints[i].Value = n.Uint64()
outpoints[i].BigValue = ""
}
}
}

// TODO: Remove once broken contracts are migrated
paymentCoin := preferredOrder.Payment.AmountCurrency.Code
_, err = n.LookupCurrency(paymentCoin)
Expand Down Expand Up @@ -563,9 +575,15 @@ func (n *OpenBazaarNode) CloseDispute(orderID string, buyerPercentage, vendorPer
// Calculate total out value
totalOut := big.NewInt(0)
for _, o := range outpoints {
n, ok := new(big.Int).SetString(o.BigValue, 10)
if !ok {
return errors.New("invalid total out amount")
var n *big.Int
if o.Value > 0 {
n = big.NewInt(int64(o.Value))
} else {
ok := false
n, ok = new(big.Int).SetString(o.BigValue, 10)
if !ok {
return errors.New("invalid amount")
}
}
totalOut = new(big.Int).Add(totalOut, n)
}
Expand Down Expand Up @@ -640,9 +658,15 @@ func (n *OpenBazaarNode) CloseDispute(orderID string, buyerPercentage, vendorPer
if err != nil {
return err
}
n, ok := new(big.Int).SetString(o.BigValue, 10)
if !ok {
return errors.New("invalid amount")
var n *big.Int
if o.Value > 0 {
n = big.NewInt(int64(o.Value))
} else {
ok := false
n, ok = new(big.Int).SetString(o.BigValue, 10)
if !ok {
return errors.New("invalid amount")
}
}
input := wallet.TransactionInput{
OutpointHash: decodedHash,
Expand Down Expand Up @@ -738,25 +762,39 @@ func (n *OpenBazaarNode) CloseDispute(orderID string, buyerPercentage, vendorPer
if out, ok := outMap["buyer"]; ok {
payout.BuyerOutput = &pb.DisputeResolution_Payout_Output{
ScriptOrAddress: &pb.DisputeResolution_Payout_Output_Address{Address: buyerAddr.String()},
BigAmount: out.Value.String(),
}
if preferredContract.VendorListings[0].Metadata.Version >= repo.ListingVersion {
payout.BuyerOutput.BigAmount = out.Value.String()
} else {
payout.BuyerOutput.Amount = out.Value.Uint64()
}
}
if out, ok := outMap["vendor"]; ok {
payout.VendorOutput = &pb.DisputeResolution_Payout_Output{
ScriptOrAddress: &pb.DisputeResolution_Payout_Output_Address{Address: vendorAddr.String()},
BigAmount: out.Value.String(),
}
if preferredContract.VendorListings[0].Metadata.Version >= repo.ListingVersion {
payout.VendorOutput.BigAmount = out.Value.String()
} else {
payout.VendorOutput.Amount = out.Value.Uint64()
}
}
if out, ok := outMap["moderator"]; ok {
payout.ModeratorOutput = &pb.DisputeResolution_Payout_Output{
ScriptOrAddress: &pb.DisputeResolution_Payout_Output_Address{Address: modAddr.String()},
BigAmount: out.Value.String(),
}
if preferredContract.VendorListings[0].Metadata.Version >= repo.ListingVersion {
payout.ModeratorOutput.BigAmount = out.Value.String()
} else {
payout.ModeratorOutput.Amount = out.Value.Uint64()
}
}

payout.PayoutCurrency = &pb.CurrencyDefinition{
Code: preferredOrder.Payment.AmountCurrency.Code,
Divisibility: preferredOrder.Payment.AmountCurrency.Divisibility,
if preferredContract.VendorListings[0].Metadata.Version >= repo.ListingVersion {
payout.PayoutCurrency = &pb.CurrencyDefinition{
Code: preferredOrder.Payment.AmountCurrency.Code,
Divisibility: preferredOrder.Payment.AmountCurrency.Divisibility,
}
}

d.Payout = payout
Expand Down Expand Up @@ -1210,6 +1248,12 @@ func (n *OpenBazaarNode) ReleaseFunds(contract *pb.RicardianContract, records []

peerID := order.BuyerID.PeerID

// Build, sign, and broadcast transaction
txnID, err := wal.Multisign(inputs, outputs, mySigs, moderatorSigs, redeemScriptBytes, *big.NewInt(0), true)
if err != nil {
return err
}

// Update database
if n.IpfsNode.Identity.Pretty() == order.BuyerID.PeerID {
err = n.Datastore.Purchases().Put(orderID, *contract, pb.OrderState_DECIDED, true)
Expand All @@ -1221,12 +1265,6 @@ func (n *OpenBazaarNode) ReleaseFunds(contract *pb.RicardianContract, records []
log.Errorf("ReleaseFunds error updating database: %s", err.Error())
}

// Build, sign, and broadcast transaction
txnID, err := wal.Multisign(inputs, outputs, mySigs, moderatorSigs, redeemScriptBytes, *big.NewInt(0), true)
if err != nil {
return err
}

err = n.SendOrderPayment(&SpendResponse{
Txid: util.NormalizeAddress(hexutil.Encode(txnID)),
Currency: &currencyDef,
Expand Down
Loading