Skip to content

Commit f1ab4bf

Browse files
committed
Merge commit 'v0.13.8-rc1' into development
* commit '1ab22c8e2fb4e59122d38bb2d7cb0dbee890efee': (30 commits) Vendor latest changes for multiwallet Error on no inputs available (OpenBazaar#1919) Migrate to AddWatchedAddresses (OpenBazaar#1920) Do not mark wallet address as watched + fix earlier txn errors Update make openbazaard command to not include tag Point Dockfiles at public Docker Hub repo; Add make help Remove unused imports Fix linter issues Update transports Update Bitcoin Cash rates dialer Refactor Dockerfile.dev to derive from latest Dockerfile.qa Refactor Dockerfile.qa Add openbazaard and qa targets to Makefile; Fix docker build targets Add QA docker commands to Makefile QA dockerfile Add qa.sh script Fix transports for message retriever and images Fix formatted logging messages Add dates to timestamps for desktop server Add date to the timestamps in Haven logging ...
2 parents 6e0af66 + 1ab22c8 commit f1ab4bf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+491
-6387
lines changed

Dockerfile.dev

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,4 @@
1-
FROM golang:1.11
2-
VOLUME /var/lib/openbazaar
3-
4-
RUN wget https://www.python.org/ftp/python/3.6.0/Python-3.6.0.tgz && \
5-
tar xvf Python-3.6.0.tgz && \
6-
cd Python-3.6.0 && \
7-
./configure --enable-optimizations && \
8-
make -j8
9-
RUN apt-get update && apt-get install -yq zlib1g-dev libssl-dev unzip
10-
RUN cd Python-3.6.0 && \
11-
make altinstall && \
12-
ln -s /usr/local/bin/python3.6 /usr/local/bin/python3
13-
14-
COPY ./qa/requirements.txt ./requirements.txt
15-
16-
RUN pip3.6 install --upgrade pip && \
17-
pip3.6 install -r requirements.txt && \
18-
wget https://bitcoin.org/bin/bitcoin-core-0.16.3/bitcoin-0.16.3-x86_64-linux-gnu.tar.gz && \
19-
tar -xvzf bitcoin-0.16.3-x86_64-linux-gnu.tar.gz -C /opt
20-
21-
RUN wget https://github.com/google/protobuf/releases/download/v3.6.0/protoc-3.6.0-linux-x86_64.zip && \
22-
unzip ./protoc-3.6.0-linux-x86_64.zip -x readme.txt && \
23-
mv ./include/* /usr/local/include/ && \
24-
mv ./bin/protoc /usr/local/bin/ && \
25-
rm -rf ./include ./bin
1+
FROM openbazaar/server-qa:0.10
262

273
WORKDIR /go/src/github.com/phoreproject/openbazaar-go
284
RUN go get -u github.com/gogo/protobuf/proto \

Dockerfile.qa

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
FROM golang:1.11
2+
3+
ENV BITCOIND_VERSION=0.16.3
4+
ENV BITCOIND_PATH=/opt/bitcoin-${BITCOIND_VERSION}
5+
6+
# software installs, from most stable to most volatile
7+
RUN apt-get update -y
8+
RUN apt-get install -yq software-properties-common \
9+
zlib1g-dev \
10+
libssl-dev \
11+
unzip \
12+
python3 \
13+
python3-pip
14+
15+
RUN wget https://github.com/google/protobuf/releases/download/v3.6.0/protoc-3.6.0-linux-x86_64.zip && \
16+
unzip ./protoc-3.6.0-linux-x86_64.zip -x readme.txt && \
17+
mv ./include/* /usr/local/include/ && \
18+
mv ./bin/protoc /usr/local/bin/ && \
19+
rm -rf ./include ./bin
20+
21+
COPY ./qa/requirements.txt ./requirements.txt
22+
23+
RUN python3 -m pip install --upgrade pip && \
24+
pip install -r ./requirements.txt && \
25+
wget https://bitcoin.org/bin/bitcoin-core-0.16.3/bitcoin-${BITCOIND_VERSION}-x86_64-linux-gnu.tar.gz && \
26+
tar -xvzf bitcoin-${BITCOIND_VERSION}-x86_64-linux-gnu.tar.gz -C /opt
27+
28+
WORKDIR /go/src/github.com/OpenBazaar/openbazaar-go
29+
30+
COPY ./Makefile ./Makefile
31+
32+
VOLUME /go/src/github.com/OpenBazaar/openbazaar-go
33+
34+
CMD make qa_test

Makefile

Lines changed: 69 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,31 @@
1+
.DEFAULT_GOAL := help
2+
3+
##
4+
## Global ENV vars
5+
##
6+
7+
GIT_SHA ?= $(shell git rev-parse --short=8 HEAD)
8+
GIT_TAG ?= $(shell git describe --tags --abbrev=0)
9+
10+
##
11+
## Helpful Help
12+
##
13+
14+
.PHONY: help
15+
help:
16+
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
17+
18+
119
##
220
## Building
321
##
422

5-
ios_framework:
23+
.PHONY: ios_framework
24+
ios_framework: ## Build iOS Framework for mobile
625
gomobile bind -target=ios github.com/phoreproject/openbazaar-go/mobile
726

8-
android_framework:
27+
.PHONY: android_framework
28+
android_framework: ## Build Android Framework for mobile
929
gomobile bind -target=android github.com/phoreproject/openbazaar-go/mobile
1030

1131
##
@@ -17,20 +37,57 @@ P_ANY = Mgoogle/protobuf/any.proto=github.com/golang/protobuf/ptypes/any
1737
PKGMAP = $(P_TIMESTAMP),$(P_ANY)
1838

1939
.PHONY: protos
20-
protos:
40+
protos: ## Build go files for proto definitions
2141
cd pb/protos && PATH=$(PATH):$(GOPATH)/bin protoc --go_out=$(PKGMAP):.. *.proto
2242

43+
44+
##
45+
## Testing
46+
##
47+
OPENBAZAARD_NAME ?= openbazaard-$(GIT_SHA)
48+
BITCOIND_PATH ?= .
49+
50+
.PHONY: openbazaard
51+
openbazaard: ## Build daemon
52+
$(info "Building openbazaar daemon...")
53+
go build -o ./$(OPENBAZAARD_NAME) .
54+
55+
.PHONY: qa_test
56+
qa_test: openbazaard ## Run QA test suite against current working copy
57+
$(info "Running QA... (openbazaard: ../$(OPENBAZAARD_NAME) bitcoind: $(BITCOIND_PATH)/bin/bitcoind)")
58+
(cd qa && ./runtests.sh ../$(OPENBAZAARD_NAME) $(BITCOIND_PATH)/bin/bitcoind)
59+
2360
##
2461
## Docker
2562
##
26-
DOCKER_PROFILE ?= openbazaar
27-
DOCKER_VERSION ?= $(shell git describe --tags --abbrev=0)
28-
DOCKER_IMAGE_NAME ?= $(DOCKER_PROFILE)/server:$(DOCKER_VERSION)
63+
PUBLIC_DOCKER_REGISTRY ?= openbazaar
64+
QA_DEV_TAG ?= 0.10
65+
66+
DOCKER_SERVER_IMAGE_NAME ?= $(PUBLIC_DOCKER_REGISTRY)/server:$(GIT_TAG)
67+
DOCKER_QA_IMAGE_NAME ?= $(PUBLIC_DOCKER_REGISTRY)/server-qa:$(QA_DEV_TAG)
68+
DOCKER_DEV_IMAGE_NAME ?= $(PUBLIC_DOCKER_REGISTRY)/server-dev:$(QA_DEV_TAG)
69+
70+
71+
.PHONY: docker_build
72+
docker_build: ## Build container for daemon
73+
docker build -t $(DOCKER_SERVER_IMAGE_NAME) .
74+
75+
.PHONY: docker_push
76+
docker_push: docker ## Push container for daemon
77+
docker push $(DOCKER_SERVER_IMAGE_NAME)
78+
79+
.PHONY: qa_docker_build
80+
qa_docker_build: ## Build container with QA test dependencies included
81+
docker build -t $(DOCKER_QA_IMAGE_NAME) -f ./Dockerfile.qa .
82+
83+
.PHONY: qa_docker_push
84+
qa_docker_push: qa_docker_build ## Push container for daemon QA test environment
85+
docker push $(DOCKER_QA_IMAGE_NAME)
2986

30-
.PHONY: docker
31-
docker:
32-
docker build -t $(DOCKER_IMAGE_NAME) .
87+
.PHONY: dev_docker_build
88+
dev_docker: ## Build container with dev dependencies included
89+
docker build -t $(DOCKER_DEV_IMAGE_NAME) -f ./Dockerfile.dev .
3390

34-
.PHONY: push_docker
35-
push_docker:
36-
docker push $(DOCKER_IMAGE_NAME)
91+
.PHONY: dev_docker_push
92+
dev_docker_push: dev_docker_build ## Push container for daemon dev environment
93+
docker push $(DOCKER_DEV_IMAGE_NAME)

api/jsonapi.go

Lines changed: 3 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1639,53 +1639,12 @@ func (i *jsonAPIHandler) POSTResyncBlockchain(w http.ResponseWriter, r *http.Req
16391639

16401640
func (i *jsonAPIHandler) GETOrder(w http.ResponseWriter, r *http.Request) {
16411641
_, orderID := path.Split(r.URL.Path)
1642-
var (
1643-
err error
1644-
isSale bool
1645-
contract *pb.RicardianContract
1646-
state pb.OrderState
1647-
funded bool
1648-
records []*wallet.TransactionRecord
1649-
read bool
1650-
paymentCoin *repo.CurrencyCode
1651-
)
1652-
contract, state, funded, records, read, paymentCoin, err = i.node.Datastore.Purchases().GetByOrderId(orderID)
1653-
if err != nil {
1654-
contract, state, funded, records, read, paymentCoin, err = i.node.Datastore.Sales().GetByOrderId(orderID)
1655-
if err != nil {
1656-
ErrorResponse(w, http.StatusNotFound, "Order not found")
1657-
return
1658-
}
1659-
isSale = true
1660-
}
1661-
resp := new(pb.OrderRespApi)
1662-
resp.Contract = contract
1663-
resp.Funded = funded
1664-
resp.Read = read
1665-
resp.State = state
16661642

1667-
// TODO: Remove once broken contracts are migrated
1668-
lookupCoin := contract.BuyerOrder.Payment.Coin
1669-
_, err = repo.LoadCurrencyDefinitions().Lookup(lookupCoin)
1670-
if err != nil {
1671-
log.Warningf("invalid BuyerOrder.Payment.Coin (%s) on order (%s)", lookupCoin, orderID)
1672-
contract.BuyerOrder.Payment.Coin = paymentCoin.String()
1673-
}
1674-
1675-
paymentTxs, refundTx, err := i.node.BuildTransactionRecords(contract, records, state)
1643+
resp, err := i.node.GetOrder(orderID)
16761644
if err != nil {
1677-
ErrorResponse(w, http.StatusInternalServerError, err.Error())
1678-
return
1679-
}
1680-
resp.PaymentAddressTransactions = paymentTxs
1681-
resp.RefundAddressTransaction = refundTx
1682-
1683-
unread, err := i.node.Datastore.Chat().GetUnreadCount(orderID)
1684-
if err != nil {
1685-
ErrorResponse(w, http.StatusInternalServerError, err.Error())
1645+
ErrorResponse(w, http.StatusNotFound, "Order not found")
16861646
return
16871647
}
1688-
resp.UnreadChatMessages = uint64(unread)
16891648

16901649
m := jsonpb.Marshaler{
16911650
EnumsAsInts: false,
@@ -1698,11 +1657,7 @@ func (i *jsonAPIHandler) GETOrder(w http.ResponseWriter, r *http.Request) {
16981657
ErrorResponse(w, http.StatusInternalServerError, err.Error())
16991658
return
17001659
}
1701-
if isSale {
1702-
i.node.Datastore.Sales().MarkAsRead(orderID)
1703-
} else {
1704-
i.node.Datastore.Purchases().MarkAsRead(orderID)
1705-
}
1660+
17061661
SanitizedResponseM(w, out, new(pb.OrderRespApi))
17071662
}
17081663

cmd/start.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,11 @@ import (
6262
)
6363

6464
var stdoutLogFormat = logging.MustStringFormatter(
65-
`%{color:reset}%{color}%{time:15:04:05.000} [%{level}] [%{module}/%{shortfunc}] %{message}`,
65+
`%{color:reset}%{color}%{time:2006-01-02 15:04:05.000} [%{level}] [%{module}/%{shortfunc}] %{message}`,
6666
)
6767

6868
var fileLogFormat = logging.MustStringFormatter(
69-
`%{time:15:04:05.000} [%{level}] [%{module}/%{shortfunc}] %{message}`,
69+
`%{time:2006-01-02 15:04:05.000} [%{level}] [%{module}/%{shortfunc}] %{message}`,
7070
)
7171

7272
var ErrNoGateways = errors.New("no gateway addresses configured")

core/completion.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,10 @@ func (n *OpenBazaarNode) ReleaseFundsAfterTimeout(contract *pb.RicardianContract
349349
}
350350
}
351351

352+
if len(txInputs) == 0 {
353+
return errors.New("there are no inputs available for this transaction")
354+
}
355+
352356
chaincode, err := hex.DecodeString(contract.BuyerOrder.Payment.Chaincode)
353357
if err != nil {
354358
return err

core/images.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
_ "image/png"
1010
"io"
1111
"io/ioutil"
12-
"net"
1312
"net/http"
1413
netUrl "net/url"
1514
"os"
@@ -164,12 +163,14 @@ func (n *OpenBazaarNode) FetchImage(peerID string, imageType string, size string
164163

165164
// GetBase64Image - fetch the image and return it as base64 encoded string
166165
func (n *OpenBazaarNode) GetBase64Image(url string) (base64ImageData, filename string, err error) {
167-
dial := net.Dial
166+
var client *http.Client
168167
if n.TorDialer != nil {
169-
dial = n.TorDialer.Dial
168+
tbTransport := &http.Transport{Dial: n.TorDialer.Dial}
169+
client = &http.Client{Transport: tbTransport, Timeout: time.Second * 30}
170+
} else {
171+
client = &http.Client{Timeout: time.Second * 30}
170172
}
171-
tbTransport := &http.Transport{Dial: dial}
172-
client := &http.Client{Transport: tbTransport, Timeout: time.Second * 30}
173+
173174
resp, err := client.Get(url)
174175
if err != nil {
175176
return "", "", err

core/order.go

Lines changed: 61 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,64 @@ const (
7878
CryptocurrencyPurchasePaymentAddressMaxLength = 512
7979
)
8080

81+
// GetOrder - provide API response order object by orderID
82+
func (n *OpenBazaarNode) GetOrder(orderID string) (*pb.OrderRespApi, error) {
83+
var (
84+
err error
85+
isSale bool
86+
contract *pb.RicardianContract
87+
state pb.OrderState
88+
funded bool
89+
records []*wallet.TransactionRecord
90+
read bool
91+
paymentCoin *repo.CurrencyCode
92+
)
93+
contract, state, funded, records, read, paymentCoin, err = n.Datastore.Purchases().GetByOrderId(orderID)
94+
if err != nil {
95+
contract, state, funded, records, read, paymentCoin, err = n.Datastore.Sales().GetByOrderId(orderID)
96+
if err != nil {
97+
return nil, errors.New("order not found")
98+
}
99+
isSale = true
100+
}
101+
resp := new(pb.OrderRespApi)
102+
resp.Contract = contract
103+
resp.Funded = funded
104+
resp.Read = read
105+
resp.State = state
106+
107+
// TODO: Remove once broken contracts are migrated
108+
lookupCoin := contract.BuyerOrder.Payment.Coin
109+
_, err = repo.LoadCurrencyDefinitions().Lookup(lookupCoin)
110+
if err != nil {
111+
log.Warningf("invalid BuyerOrder.Payment.Coin (%s) on order (%s)", lookupCoin, orderID)
112+
contract.BuyerOrder.Payment.Coin = paymentCoin.String()
113+
}
114+
115+
paymentTxs, refundTx, err := n.BuildTransactionRecords(contract, records, state)
116+
if err != nil {
117+
log.Errorf(err.Error())
118+
return nil, err
119+
}
120+
resp.PaymentAddressTransactions = paymentTxs
121+
resp.RefundAddressTransaction = refundTx
122+
123+
unread, err := n.Datastore.Chat().GetUnreadCount(orderID)
124+
if err != nil {
125+
log.Errorf(err.Error())
126+
return nil, err
127+
}
128+
resp.UnreadChatMessages = uint64(unread)
129+
130+
if isSale {
131+
n.Datastore.Sales().MarkAsRead(orderID)
132+
} else {
133+
n.Datastore.Purchases().MarkAsRead(orderID)
134+
}
135+
136+
return resp, nil
137+
}
138+
81139
// Purchase - add ricardian contract
82140
func (n *OpenBazaarNode) Purchase(data *PurchaseData) (orderID string, paymentAddress string, paymentAmount uint64, vendorOnline bool, err error) {
83141
contract, err := n.createContractWithOrder(data)
@@ -213,7 +271,7 @@ func prepareModeratedOrderContract(data *PurchaseData, n *OpenBazaarNode, contra
213271
payment.Chaincode = hex.EncodeToString(chaincode)
214272
contract.BuyerOrder.RefundFee = wal.GetFeePerByte(wallet.NORMAL)
215273

216-
err = wal.AddWatchedAddress(addr)
274+
err = wal.AddWatchedAddresses(addr)
217275
if err != nil {
218276
return nil, err
219277
}
@@ -250,7 +308,7 @@ func processOnlineDirectOrder(resp *pb.Message, n *OpenBazaarNode, wal wallet.Wa
250308
if err != nil {
251309
return "", "", 0, false, err
252310
}
253-
err = wal.AddWatchedAddress(addr)
311+
err = wal.AddWatchedAddresses(addr)
254312
if err != nil {
255313
return "", "", 0, false, err
256314
}
@@ -298,7 +356,7 @@ func processOfflineDirectOrder(n *OpenBazaarNode, wal wallet.Wallet, contract *p
298356
payment.RedeemScript = hex.EncodeToString(redeemScript)
299357
payment.Chaincode = hex.EncodeToString(chaincode)
300358

301-
err = wal.AddWatchedAddress(addr)
359+
err = wal.AddWatchedAddresses(addr)
302360
if err != nil {
303361
return "", "", 0, false, err
304362
}

0 commit comments

Comments
 (0)