Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Qa test #351

Merged
merged 4 commits into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions docker-compose/lbc-deployer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ RUN gitBranch=${LBC_GIT_BRANCH} && \
git fetch --depth 1 origin "$gitBranch" && \
git checkout "$gitBranch"

COPY --chown=node truffle-config.patch ./

RUN git apply truffle-config.patch
#COPY --chown=node truffle-config.patch ./
#
#RUN git apply truffle-config.patch

RUN npm ci

Expand Down
4 changes: 3 additions & 1 deletion docker-compose/local/.env.regtest
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,6 @@ CAPTCHA_SECRET_KEY=
CAPTCHA_SITE_KEY=
CAPTCHA_THRESHOLD=0.8
DISABLE_CAPTCHA=true
PROVIDER_TYPE=both
PROVIDER_TYPE=both

DAO_FEE_COLLECTOR_ADDRESS=0x86B6534687A176A476C16083a373fB9Fe4FAb449
2 changes: 2 additions & 0 deletions docker-compose/local/.env.testnet
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,5 @@ CAPTCHA_SITE_KEY=
CAPTCHA_THRESHOLD=0.8
DISABLE_CAPTCHA=false
PROVIDER_TYPE=both

DAO_FEE_COLLECTOR_ADDRESS=0x86B6534687A176A476C16083a373fB9Fe4FAb449
1 change: 1 addition & 0 deletions docker-compose/local/docker-compose.lps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ services:
- DISABLE_CAPTCHA
- BTC_WALLET_PASSWORD
- BTC_ENCRYPTED_WALLET
- DAO_FEE_COLLECTOR_ADDRESS
ports:
- "8080:8080"
volumes:
Expand Down
36 changes: 23 additions & 13 deletions http/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -831,6 +831,7 @@ func (s *Server) getQuoteHandler(w http.ResponseWriter, r *http.Request) {

var gas uint64
gas, err = s.rsk.EstimateGas(qr.CallEoaOrContractAddress, big.NewInt(int64(qr.ValueToTransfer)), []byte(qr.CallContractArguments))

if err != nil {
log.Error(ErrorEstimatingGas, err.Error())
customError := NewServerError(ErrorEstimatingGas, make(Details), true)
Expand All @@ -845,6 +846,25 @@ func (s *Server) getQuoteHandler(w http.ResponseWriter, r *http.Request) {
return
}

daoFeePercentage, err := s.rsk.GetDaoFeePercentage()

if err != nil {
log.Error(ErrorRetrievingDaoFeePercentage, err.Error())
customError := NewServerError(ErrorRetrievingDaoFeePercentage, make(map[string]interface{}), true)
ResponseError(w, customError, http.StatusInternalServerError)
return
}

daoFeeAmount := qr.ValueToTransfer * daoFeePercentage / 100

gasDao, err := s.rsk.EstimateGas(os.Getenv("DAO_FEE_COLLECTOR_ADDRESS"), big.NewInt(int64(daoFeeAmount)), make([]byte, 0))
if err != nil {
log.Error(ErrorEstimatingGas, err.Error())
customError := NewServerError(ErrorEstimatingGas, make(Details), true)
ResponseError(w, customError, http.StatusInternalServerError)
return
}

var quotes []*QuoteReturn
fedAddress, err := s.rsk.GetFedAddress()
if err != nil {
Expand All @@ -863,21 +883,11 @@ func (s *Server) getQuoteHandler(w http.ResponseWriter, r *http.Request) {
}
minLockTxValueInWei := types.SatoshiToWei(minLockTxValueInSatoshi.Uint64())

daoFeePercentage, err := s.rsk.GetDaoFeePercentage()

if err != nil {
log.Error(ErrorRetrievingDaoFeePercentage, err.Error())
customError := NewServerError(ErrorRetrievingDaoFeePercentage, make(map[string]interface{}), true)
ResponseError(w, customError, http.StatusInternalServerError)
return
}

daoFeeAmount := qr.ValueToTransfer * daoFeePercentage / 100

getQuoteFailed := false
amountBelowMinLockTxValue := false
q := parseReqToQuote(qr, s.rsk.GetLBCAddress(), fedAddress, gas, daoFeeAmount)
pq, err := s.provider.GetQuote(q, gas, types.NewBigWei(price))
totalGas := gas + gasDao
q := parseReqToQuote(qr, s.rsk.GetLBCAddress(), fedAddress, totalGas, daoFeeAmount)
pq, err := s.provider.GetQuote(q, totalGas, types.NewBigWei(price))
if err != nil {
log.Error("error getting quote: ", err)
getQuoteFailed = true
Expand Down
2 changes: 1 addition & 1 deletion http/watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ type BTCAddressPegOutWatcher struct {
}

const (
pegInGasLim = 1500000
pegInGasLim = 2500000
CFUExtraGas = 180000
WatcherClosedError = "watcher is closed; cannot handle OnNewConfirmation; hash: %v"
WatcherOnExpireError = "watcher is closed; cannot handle OnExpire; hash: %v"
Expand Down
Loading