diff --git a/docker-compose/lbc-deployer/Dockerfile b/docker-compose/lbc-deployer/Dockerfile index 44724d7b..45170c2c 100644 --- a/docker-compose/lbc-deployer/Dockerfile +++ b/docker-compose/lbc-deployer/Dockerfile @@ -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 diff --git a/docker-compose/local/.env.regtest b/docker-compose/local/.env.regtest index b97418d4..25e69ab9 100644 --- a/docker-compose/local/.env.regtest +++ b/docker-compose/local/.env.regtest @@ -84,4 +84,6 @@ CAPTCHA_SECRET_KEY= CAPTCHA_SITE_KEY= CAPTCHA_THRESHOLD=0.8 DISABLE_CAPTCHA=true -PROVIDER_TYPE=both \ No newline at end of file +PROVIDER_TYPE=both + +DAO_FEE_COLLECTOR_ADDRESS=0x86B6534687A176A476C16083a373fB9Fe4FAb449 \ No newline at end of file diff --git a/docker-compose/local/.env.testnet b/docker-compose/local/.env.testnet index a9f0645b..225fa251 100644 --- a/docker-compose/local/.env.testnet +++ b/docker-compose/local/.env.testnet @@ -44,3 +44,5 @@ CAPTCHA_SITE_KEY= CAPTCHA_THRESHOLD=0.8 DISABLE_CAPTCHA=false PROVIDER_TYPE=both + +DAO_FEE_COLLECTOR_ADDRESS=0x86B6534687A176A476C16083a373fB9Fe4FAb449 diff --git a/docker-compose/local/docker-compose.lps.yml b/docker-compose/local/docker-compose.lps.yml index 82627530..2196ba90 100644 --- a/docker-compose/local/docker-compose.lps.yml +++ b/docker-compose/local/docker-compose.lps.yml @@ -78,6 +78,7 @@ services: - DISABLE_CAPTCHA - BTC_WALLET_PASSWORD - BTC_ENCRYPTED_WALLET + - DAO_FEE_COLLECTOR_ADDRESS ports: - "8080:8080" volumes: diff --git a/http/server.go b/http/server.go index ca10032a..94ebe184 100644 --- a/http/server.go +++ b/http/server.go @@ -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) @@ -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 { @@ -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 diff --git a/http/watcher.go b/http/watcher.go index d9bb9bdf..086b1980 100644 --- a/http/watcher.go +++ b/http/watcher.go @@ -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"