stacks-network / sbtc-developer-release

sBTC primitives, signer components, helper tools
https://sbtc.tech
MIT License
1.98k stars 23 forks source link

sbtc-bridge-web is statically configured #230

Open EmbeddedAndroid opened 1 year ago

EmbeddedAndroid commented 1 year ago

Expected Behavior

The sbtc-bridge-web app can be configured without source code changes

Actual Behavior

https://github.com/EmbeddedAndroid/sbtc-bridge-web/commit/2b13c9bd3024f7a965cae042ef57fe82fbdd808f

Steps to Reproduce

Attempt to use the sbtc-bridge-web interface with leather wallet after a mint.

Screenshots or Videos

EmbeddedAndroid commented 1 year ago

When I manually configure the bridge, the api explodes with

fetchUtxoSet: addressValidation: undefined : getAddressInfo internal error: undefined
Error: Unable to retrieve utxo set from mempool?
    at fetchUTXOs (file:///app/sbtc-bridge-api/dist/src/lib/bitcoin/api_mempool.js:79:19)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async WalletController.fetchUtxoSet (file:///app/sbtc-bridge-api/dist/src/routes/bitcoin/BitcoinRPCController.js:298:27)
    at async file:///app/sbtc-bridge-api/dist/src/routes/bitcoinRoutes.js:120:26
fetchUtxoSet: fetchUTXOs: undefined : utxos is not iterable
GET /bridge-api/testnet/v1/btc/wallet/address/undefined/utxos?verbose=true 304 - - 82.817 ms
/address/balances/:stxAddress/:cardinal/:ordinal
GET /bridge-api/testnet/v1/sbtc/address/balances/ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM/tb1q3tj2fr9scwmcw3rq5m6jslva65f2rqjxt2t0zh/tb1pte5zmd7qzj4hdu45lh9mmdm0nwq3z35pwnxmzkwld6y0a8g83nnq6ts2d4 - - - - ms
Error fetching sbtc alpha data from sbtc contrcat
get-bitcoin-wallet-public-key: getting key: 0390a5cac7c33fda49f70bc1b0866fa0ba7a9440d9de647fecb8132ceb76a94dfa
Error fetching sbtc alpha data from sbtc contrcat
{
  type: 'principal',
  value: 'ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM'
}
Error in routes:  Error: private key must be 32 bytes, hex or bigint, not undefined
    at Object.normPrivateKeyToScalar (file:///app/sbtc-bridge-api/node_modules/@noble/curves/esm/abstract/weierstrass.js:158:19)
    at schnorrGetExtPubKey (file:///app/sbtc-bridge-api/node_modules/@noble/curves/esm/secp256k1.js:110:30)
    at Object.schnorrGetPublicKey [as getPublicKey] (file:///app/sbtc-bridge-api/node_modules/@noble/curves/esm/secp256k1.js:141:12)
    at TransactionController.getKeys (file:///app/sbtc-bridge-api/dist/src/routes/bitcoin/BitcoinRPCController.js:51:50)
    at file:///app/sbtc-bridge-api/dist/src/routes/sbtcRoutes.js:147:40
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
GET /bridge-api/testnet/v1/sbtc/init-ui 500 164 - 105.073 ms
An error occurred fetching sbtc data.
==========================================================================
getAddressInfo internal error: tb1q3tj2fr9scwmcw3rq5m6jslva65f2rqjxt2t0zh : -18 : Requested wallet does not exist or is not loaded
==========================================================================
fetchUtxoSet: addressValidation: tb1q3tj2fr9scwmcw3rq5m6jslva65f2rqjxt2t0zh : getAddressInfo internal error: tb1q3tj2fr9scwmcw3rq5m6jslva65f2rqjxt2t0zh
GET /bridge-api/testnet/v1/btc/wallet/address/tb1q3tj2fr9scwmcw3rq5m6jslva65f2rqjxt2t0zh/utxos?verbose=true 200 7085 - 599.526 ms
==========================================================================
getAddressInfo internal error: tb1q3tj2fr9scwmcw3rq5m6jslva65f2rqjxt2t0zh : -18 : Requested wallet does not exist or is not loaded
==========================================================================
fetchUtxoSet: addressValidation: tb1q3tj2fr9scwmcw3rq5m6jslva65f2rqjxt2t0zh : getAddressInfo internal error: tb1q3tj2fr9scwmcw3rq5m6jslva65f2rqjxt2t0zh
GET /bridge-api/testnet/v1/btc/wallet/address/tb1q3tj2fr9scwmcw3rq5m6jslva65f2rqjxt2t0zh/utxos?verbose=true 200 7085 - 590.720 ms
EmbeddedAndroid commented 1 year ago

@radicleart I might need your help understanding these errors.

radicleart commented 1 year ago

Will look into and try to reproduce.

On Thu, 5 Oct 2023, 19:18 0x1, @.***> wrote:

@radicleart https://github.com/radicleart I might need your help understanding these errors.

— Reply to this email directly, view it on GitHub https://github.com/stacks-network/sbtc/issues/230#issuecomment-1749421385, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABBORIMDGNPPYE3NOMAJQULX532XHAVCNFSM6AAAAAA5UMTXASVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONBZGQZDCMZYGU . You are receiving this because you were mentioned.Message ID: @.***>

radicleart commented 1 year ago

@EmbeddedAndroid i just built but the http://stacks-api:3999 service isn't running - i think i saw an open issue for this?

Another issue is the containers for the web and maybe api are pretty old. Is there a way to remove or override the caching policy for these two containers - main changes regularly and the two apps are coupled?

Aside this there are dependence on contract deployment the bridge won't function until its linked to a contract and also on the leather on devnet issue - i think this is the cause of UTXO related errors as its using the testnet addresses in the wallet to fetch UTXOs.

.

EmbeddedAndroid commented 1 year ago

@EmbeddedAndroid i just built but the http://stacks-api:3999 service isn't running - i think i saw an open issue for this?

stacks-api shouldn't have any issues, if the stacks-explorer is working the api is too. One thing to check, the stacks-api hostname only resolves when the containers are deployed together i.e. up.sh If it's running seperately, you'll want to use 127.0.0.1:3999.

Another issue is the containers for the web and maybe api are pretty old. Is there a way to remove or override the caching policy for these two containers - main changes regularly and the two apps are coupled?

The only way I think we can do this now is

docker compose build sbtc-bridge-web --no-cache docker compose build sbtc-bridge-api --no-cache

However that isn't a fix for the issue your raising. Let me research a better solution.

Aside this there are dependence on contract deployment the bridge won't function until its linked to a contract and also on the leather on devnet issue - i think this is the cause of UTXO related errors as its using the testnet addresses in the wallet to fetch UTXOs.

What is the process to link the bridge to a contract?

I added this: https://github.com/EmbeddedAndroid/sbtc-bridge-web/commit/2b13c9bd3024f7a965cae042ef57fe82fbdd808f#diff-0b4f5977a52cef50ed20e7cdf9761795df9ee1cb3b5e5ea45edeb9394e8a47ffL31 but wasn't sure if I needed to do something else.

radicleart commented 1 year ago

Thanks i can see stacks api now.

The contract is set on the API via environment parameter in docker compose. Bridge will see it once its deployed.

AshtonStephens commented 1 year ago

Thanks i can see stacks api now.

The contract is set on the API via environment parameter in docker compose. Bridge will see it once its deployed.

@radicleart I'm going to assign this to you. Are you unblocked on this now?

radicleart commented 1 year ago

Hey @AshtonStephens - i am looking at this but don't think the bridge will work on deven until the Leather wallet supports (this is closed bu the the work is ongoing?) regtest Bitcoin addresses - part of the error above is the bridge trying to fetch UTXOs from regtest using the testnet addresses in the wallet.

In meantime I've prioritised trying to run Romeo on testnet against the Bridge.

radicleart commented 1 year ago

Working to fix this and stumbled on this issue https://github.com/getumbrel/umbrel-os/issues/248 that affects the bridge on devnet. the mempool /:address/utxo, that the api relies on, is not implemented in mempool devnet (its only supported in testnet/mainnet).

Looking for workarounds for this.