bitpay / bitcore

A full stack for bitcoin and blockchain-based applications
https://bitcore.io/
MIT License
4.81k stars 2.08k forks source link

Problem running bitcore-wallet shell scripts from Docker container #3561

Closed speculees closed 1 year ago

speculees commented 1 year ago

Hello, Bitpay team! I love your work and I often reference your project as a good starting point for learning blockchain tech. However, many of my friends that are starting out have difficulties understanding how to set the bitcoin node, what is necessary and how to configure the services. In order to help them out I wanted to create a docker project that sandboxes the node and all the dependencies in regtest so that they can get the feel for the system... Anyway, I set up the Docker services and it all seems connected and working. I also cloned and installed the project again on the host. I am able to create wallet and send transactions to bws from host, but I am unable to do so from docker container. I have setup the project https://github.com/speculees/bitpay . Please give it a look if you have the time. This is the error I am dealing with.


root@THNIKPAD-P50:/home/bitpay/bitcore/packages/bitcore-wallet/bin# ./wallet create -th http://localhost:3232 alice 1-1

/home/bitpay/bitcore/packages/bitcore-wallet/node_modules/bitcore-wallet-client/node_modules/sjcl/sjcl.js:20
sjcl.mode.ccm={name:"ccm",encrypt:function(a,b,c,d,e){var f,g=b.slice(0),h=sjcl.bitArray,l=h.bitLength(c)/8,k=h.bitLength(g)/8;e=e||64;d=d||[];7>l&&q(new sjcl.exception.invalid("ccm: iv must be at least 7 bytes"));for(f=2;4>f&&k>>>8*f;f++);f<15-l&&(f=15-l);c=h.clamp(c,8*(15-f));b=sjcl.mode.ccm.L(a,b,c,d,e,f);g=sjcl.mode.ccm.p(a,g,c,b,e,f);return h.concat(g.data,g.tag)},decrypt:function(a,b,c,d,e){e=e||64;d=d||[];var f=sjcl.bitArray,g=f.bitLength(c)/8,h=f.bitLength(b),l=f.clamp(b,h-e),k=f.bitSlice(b,
                                                                ^
TypeError: Cannot read properties of undefined (reading 'slice')
    at Object.encrypt (/home/bitpay/bitcore/packages/bitcore-wallet/node_modules/bitcore-wallet-client/node_modules/sjcl/sjcl.js:20:65)
    at Object.Y (/home/bitpay/bitcore/packages/bitcore-wallet/node_modules/bitcore-wallet-client/node_modules/sjcl/sjcl.js:48:468)
    at Object.encrypt (/home/bitpay/bitcore/packages/bitcore-wallet/node_modules/bitcore-wallet-client/node_modules/sjcl/sjcl.js:49:49)
    at Function.encryptMessage (/home/bitpay/bitcore/packages/bitcore-wallet/node_modules/bitcore-wallet-client/src/lib/common/utils.ts:59:17)
    at API._doJoinWallet (/home/bitpay/bitcore/packages/bitcore-wallet/node_modules/bitcore-wallet-client/src/lib/api.ts:787:32)
    at /home/bitpay/bitcore/packages/bitcore-wallet/node_modules/bitcore-wallet-client/src/lib/api.ts:962:12
    at fn (/home/bitpay/bitcore/packages/bitcore-wallet/node_modules/bitcore-wallet-client/src/lib/request.ts:132:14)
    at Request.callback (/home/bitpay/bitcore/packages/bitcore-wallet/node_modules/superagent/src/node/index.js:878:12)
    at fn (/home/bitpay/bitcore/packages/bitcore-wallet/node_modules/superagent/src/node/index.js:1117:18)
    at IncomingMessage.<anonymous> (/home/bitpay/bitcore/packages/bitcore-wallet/node_modules/superagent/src/node/parsers/json.js:19:7)
    at IncomingMessage.emit (node:events:525:35)
    at endReadableNT (node:internal/streams/readable:1359:12)
    at processTicksAndRejections (node:internal/process/task_queues:82:21)```
escottalexander commented 1 year ago

Neat project. Love to see it all dockerized.

How are you creating the wallets? The error seems to indicate that the type for the copayer param in bitcore-wallet-client > createWallet (api.ts:899) is not a valid string.

speculees commented 1 year ago

Thank you, I used ./wallet create -th http://127.0.0.1:3232 alice 1-1 . This works on host, but not it docker. Anyway, I managed to get it working using a Copay wallet image from Docker hub. I attempted to build my own, but had no luck. I could not get it to build in a container due to node-sass issue with node-gyp. Not sure how zmscode/bitpay-copay got it to work. My guess is he built it on host and copied the build to docker image. For now I am satisfied with this. Once again, I thank you for all your work. :)