Skip to content

feat: NWA & Alby Go#279

Merged
rolznz merged 14 commits intomasterfrom
feat/nwa
Mar 3, 2025
Merged

feat: NWA & Alby Go#279
rolznz merged 14 commits intomasterfrom
feat/nwa

Conversation

@rolznz
Copy link
Copy Markdown
Collaborator

@rolznz rolznz commented Feb 25, 2025

Closes #278

Uses Alby JS SDK to initialize an NWAClient to get an auth string: getAlby/js-sdk#298 and subscribes to wait for the user to confirm the new connection. Once the auth string is confirmed, a new NWCClient is available which allows Bitcoin Connect to finish the connection setup.

TODO:

  • update to official version of JS SDK

image

image

image

(Needs some styling improvements, but this is the general idea)

To test it in Alby Hub, you need to create an app connection that supports create_connection, then use the examples/nwc/client/nwa-accept.js example inside the JS SDK.

Copy link
Copy Markdown
Contributor

@Dayvvo Dayvvo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @rolznz. Great that you've gotten around to this PR. Exactly what we need for self custodial wallet like flash and alby go. I haven't been able to test it successfully with alby-go but the flow looks like exactly what we need.

const {unsub} = await nwaClient.subscribe({
onSuccess: async (nwcClient) => {
nwcClient.close();
// TODO: it makes no sense to connect again
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @rolznz. Great work defining the flow for custodial wallet. this makes it easier to add connectors for self custodial walets! Haven't been able to successfully test with alby-go yet but the flow looks solid. Looking forward to implementing and testing a flash connector.

One question though, Regarding the todo you left as a comment here. I'm assuming you are using connect right now cuz the current functionaliy uses that so save the nwcurl and oher config to the store. and also calls 'getInfo'. If we're looking at removing an unnecessary connect in the future, perhaps a good approach would be to call 'getInfo' outside of connect and then save the connect info?

I'm also thinking maybe wallet service could post the allowed method, budget and other config along with the walletpubkey and lud16? We can't just use the existing config that we set in the nwa string because they are optional and could be ignored by the user when setting his preffered options for nwc string that's being created. Let me know what you think about this.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Than you!

One question though, Regarding the todo you left as a comment here. I'm assuming you are using connect right now cuz the current functionaliy uses that so save the nwcurl and oher config to the store. and also calls 'getInfo'. If we're looking at removing an unnecessary connect in the future, perhaps a good approach would be to call 'getInfo' outside of connect and then save the connect info?

The TODO is a bit hard to solve, because the connect function in the store only knows it needs to call init on a specific connector.

I'm also thinking maybe wallet service could post the allowed method, budget and other config along with the walletpubkey and lud16? We can't just use the existing config that we set in the nwa string because they are optional and could be ignored by the user when setting his preffered options for nwc string that's being created. Let me know what you think about this.

Unfortunately I had to remove the lud16 tag from the info event as it is a privacy issue - allowing someone to fetch all info events by a lightning address and from there subscribe to wallet service events for each app. It's the same issue with the other things you mentioned - it's better to call get_info because the response is end-to-end encrypted. I have a PR to move the lud16 field into get_info instead: getAlby/hub#1128

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Dayvvo the Alby Go PR has been merged to master, so you should be able to test there and scan the QR code from bitcoin connect. For testing with Alby Hub it requires using Alby Hub from the master branch and creating a new Alby Go app with 1-click connections.

We plan to merge this but are happy to adapt to feedback - have you guys started working on the Flash wallet implementation of NWA?

@rolznz
Copy link
Copy Markdown
Collaborator Author

rolznz commented Feb 25, 2025

Hey @rolznz. Great that you've gotten around to this PR. Exactly what we need for self custodial wallet like flash and alby go. I haven't been able to test it successfully with alby-go but the flow looks like exactly what we need.

@Dayvvo thanks! Alby Go is still a work in progress. I will let you know when it is ready.

For now I tested just using the example in the JS SDK:

To test it in Alby Hub, you need to create an app connection that supports create_connection, then use the examples/nwc/client/nwa-accept.js example inside the JS SDK.

@socket-security
Copy link
Copy Markdown

socket-security bot commented Feb 25, 2025

👍 Dependency issues cleared. Learn more about Socket for GitHub ↗︎

This PR previously contained dependency changes with security issues that have been resolved, removed, or ignored.

View full report↗︎

@rolznz rolznz requested review from im-adithya and reneaaron March 3, 2025 05:38
Copy link
Copy Markdown
Member

@im-adithya im-adithya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tACK

@Dayvvo Dayvvo mentioned this pull request Mar 3, 2025
@socket-security
Copy link
Copy Markdown

socket-security bot commented Mar 3, 2025

New, updated, and removed dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher
npm/@babel/code-frame@7.22.5 Transitive: environment +7 105 kB nicolo-ribaudo
npm/@babel/core@7.22.9 environment, filesystem, unsafe 0 769 kB nicolo-ribaudo
npm/@babel/generator@7.22.9 None +1 650 kB nicolo-ribaudo
npm/@babel/helper-builder-binary-assignment-operator-visitor@7.22.5 None 0 13.5 kB nicolo-ribaudo
npm/@babel/helper-compilation-targets@7.22.9 Transitive: environment, filesystem +1 114 kB nicolo-ribaudo
npm/@babel/helper-create-class-features-plugin@7.22.9 None 0 189 kB nicolo-ribaudo
npm/@babel/helper-define-polyfill-provider@0.4.1 unsafe 0 202 kB nicolo-ribaudo
npm/@babel/helper-wrap-function@7.22.9 None 0 15.4 kB nicolo-ribaudo
npm/@babel/helpers@7.22.6 None +1 1.21 MB nicolo-ribaudo
npm/@babel/highlight@7.22.5 None 0 15.6 kB nicolo-ribaudo
npm/@babel/parser@7.22.7 None 0 3.72 MB nicolo-ribaudo
npm/@babel/plugin-proposal-unicode-property-regex@7.18.6 None 0 3.48 kB nicolo-ribaudo
npm/@getalby/bitcoin-connect@3.3.0-beta.1, 3.6.33.7.0-beta.1 None 0 923 kB rolznz
npm/@getalby/lightning-tools@5.1.05.1.2 None 0 155 kB reneaaron
npm/@getalby/sdk@3.8.04.1.1 None 0 223 kB rolznz
npm/@noble/ciphers@0.5.3 None 0 624 kB paulmillr
npm/@noble/curves@1.2.0 None +1 2.1 MB paulmillr
npm/mri@1.2.0 None 0 13.3 kB lukeed
npm/node-releases@2.0.13 None 0 32.2 kB chicoxyzzy
npm/normalize-url@6.1.0 None 0 21.2 kB sindresorhus
npm/nostr-tools@2.9.4 network 0 3.33 MB fiatjaf
npm/nostr-wasm@0.1.0 None 0 688 kB fiatjaf
npm/nth-check@2.1.1 None 0 42.6 kB feedic
npm/number-is-nan@1.0.1 None 0 2.35 kB sindresorhus
npm/object-inspect@1.12.3 None 0 94.8 kB ljharb
npm/object.assign@4.1.4 None 0 1.17 MB ljharb
npm/open@8.4.2 environment, filesystem, shell 0 46.3 kB sindresorhus
npm/p-finally@1.0.0 None 0 3.11 kB sindresorhus
npm/p-limit@2.3.0 None 0 7.39 kB sindresorhus
npm/p-locate@4.1.0 None 0 7.29 kB sindresorhus
npm/p-queue@6.6.2 None 0 30.9 kB sindresorhus
npm/p-timeout@3.2.0 None 0 7.38 kB sindresorhus
npm/p-try@2.2.0 None 0 4.37 kB sindresorhus
npm/parse-json@5.2.0 None 0 5.41 kB sindresorhus
npm/pify@5.0.0 None 0 8.87 kB sindresorhus
npm/pkg-dir@4.2.0 None 0 4.75 kB sindresorhus
npm/postcss-calc@8.2.4 None 0 188 kB ludovicofischer
npm/postcss-colormin@5.3.1 None 0 8.41 kB ludovicofischer
npm/postcss-convert-values@5.1.3 None 0 11.7 kB ludovicofischer
npm/postcss-discard-comments@5.1.2 None 0 10.7 kB ludovicofischer
npm/postcss-discard-duplicates@5.1.0 None 0 8.14 kB ludovicofischer
npm/postcss-discard-empty@5.1.1 None 0 5.05 kB ludovicofischer
npm/postcss-discard-overridden@5.1.0 None 0 9.23 kB ludovicofischer
npm/postcss-load-config@3.1.4 environment, unsafe 0 22.7 kB ai
npm/postcss-merge-longhand@5.1.7 None 0 49.5 kB ludovicofischer
npm/postcss-merge-rules@5.1.4 None 0 23.4 kB ludovicofischer
npm/postcss-minify-font-values@5.1.0 None 0 18.1 kB ludovicofischer
npm/postcss-minify-gradients@5.1.1 None 0 11.1 kB ludovicofischer
npm/postcss-minify-params@5.1.4 None 0 6.69 kB ludovicofischer
npm/postcss-minify-selectors@5.2.1 None 0 9.51 kB ludovicofischer
npm/postcss-modules-extract-imports@3.0.0 None 0 12.2 kB evilebottnawi
npm/postcss-modules-local-by-default@4.0.3 None 0 21 kB evilebottnawi
npm/postcss-modules-scope@3.0.0 None 0 15 kB evilebottnawi
npm/postcss-modules-values@4.0.0 None 0 9.66 kB evilebottnawi
npm/postcss-modules@4.3.1 filesystem 0 32.3 kB outpunk
npm/postcss-normalize-charset@5.1.0 None 0 5.06 kB ludovicofischer
npm/postcss-normalize-display-values@5.1.0 None 0 7 kB ludovicofischer
npm/postcss-normalize-positions@5.1.1 None 0 8.32 kB ludovicofischer
npm/postcss-normalize-repeat-style@5.1.1 None 0 7.47 kB ludovicofischer
npm/postcss-normalize-string@5.1.0 None 0 12.3 kB ludovicofischer
npm/postcss-normalize-timing-functions@5.1.0 None 0 7.1 kB ludovicofischer
npm/postcss-normalize-unicode@5.1.1 None 0 5.92 kB ludovicofischer
npm/postcss-normalize-url@5.1.0 None 0 8.78 kB ludovicofischer
npm/postcss-normalize-whitespace@5.1.1 None 0 6.6 kB ludovicofischer
npm/postcss-ordered-values@5.1.3 None 0 28.9 kB ludovicofischer
npm/postcss-reduce-initial@5.1.2 None 0 16.6 kB ludovicofischer
npm/postcss-reduce-transforms@5.1.0 None 0 9.87 kB ludovicofischer
npm/postcss-svgo@5.1.0 None 0 13.5 kB ludovicofischer
npm/postcss-unique-selectors@5.1.1 None 0 5.21 kB ludovicofischer
npm/postcss@8.4.28 environment, filesystem 0 196 kB ai
npm/pretty-bytes@5.6.0 None 0 11.5 kB sindresorhus
npm/promise.series@0.2.0 None 0 3.55 kB rem
npm/randombytes@2.1.0 None 0 6.36 kB cwmma
npm/react@18.3.1 environment 0 318 kB react-bot
npm/regenerate-unicode-properties@10.1.0 None 0 577 kB google-wombot
npm/regenerate@1.4.2 None 0 49.2 kB mathias
npm/regenerator-transform@0.15.2 None 0 135 kB benjamn
npm/regexpu-core@5.3.2 None 0 53.8 kB google-wombot
npm/regjsparser@0.9.1 None +1 93.8 kB jviereck
npm/require-directory@2.1.1 filesystem 0 12.1 kB troygoode
npm/rollup-plugin-bundle-size@1.0.3 None 0 3.38 kB luwes
npm/rollup-plugin-postcss@4.0.2 environment 0 42.5 kB egoist
npm/rollup-plugin-terser@7.0.2 eval Transitive: environment +1 2.11 MB trysound
npm/rollup-plugin-typescript2@0.32.1 environment, eval, filesystem +1 4.82 MB ezolenko
npm/rollup-plugin-visualizer@5.9.2 filesystem 0 537 kB btd
npm/rollup-pluginutils@2.8.2 None +1 256 kB guybedford
npm/rollup@2.79.1 environment, filesystem, unsafe 0 6.7 MB lukastaegert
npm/sade@1.8.1 None 0 31.5 kB lukeed
npm/safe-array-concat@1.0.0 None 0 11.3 kB ljharb
npm/safe-buffer@5.2.1 None 0 32.1 kB feross
npm/safe-identifier@0.4.2 None 0 6.33 kB eemeli
npm/serialize-javascript@4.0.0 None 0 16.2 kB okuryu
npm/source-map-support@0.5.21 filesystem 0 85.2 kB linusu
npm/source-map@0.7.4 filesystem, network 0 226 kB eemeli
npm/sourcemap-codec@1.4.8 None 0 31.8 kB rich_harris
npm/stable@0.1.8 None 0 8.41 kB stephank
npm/string-hash@1.1.3 None 0 2.48 kB darkskyapp
npm/string.prototype.matchall@4.0.8 None 0 35.9 kB ljharb
npm/string.prototype.trim@1.2.7 None 0 31.7 kB ljharb
npm/string.prototype.trimend@1.0.6 None 0 21.2 kB ljharb
npm/string.prototype.trimstart@1.0.6 None 0 21.4 kB ljharb
npm/strip-ansi@3.0.1 None 0 3.1 kB jbnicolai
npm/style-inject@0.3.0 None 0 4.65 kB rem
npm/stylehacks@5.1.1 None 0 30.7 kB ludovicofischer
npm/supports-color@2.0.0 None 0 3.75 kB sindresorhus
npm/svgo@2.8.0 filesystem Transitive: shell +1 1.12 MB trysound
npm/tiny-glob@0.2.9 filesystem 0 12.1 kB terkelg
npm/to-fast-properties@2.0.0 None 0 3.5 kB sindresorhus
npm/typescript@4.9.5 None 0 66.8 MB typescript-bot
npm/unicode-canonical-property-names-ecmascript@2.0.0 None 0 5.01 kB google-wombot
npm/unicode-match-property-ecmascript@2.0.0 None 0 5.05 kB google-wombot
npm/unicode-match-property-value-ecmascript@2.1.0 None 0 25.7 kB google-wombot
npm/unicode-property-aliases-ecmascript@2.1.0 None 0 5.98 kB google-wombot
npm/universalify@2.0.0 None 0 4.64 kB ryanzim
npm/update-browserslist-db@1.0.11 filesystem, shell 0 13.7 kB ai
npm/use-sync-external-store@1.4.0 environment 0 27.6 kB react-bot
npm/wrap-ansi@7.0.0 None 0 10.6 kB sindresorhus
npm/y18n@5.0.8 filesystem 0 23.4 kB oss-bot
npm/yallist@3.1.1 None 0 14.8 kB isaacs
npm/yargs-parser@21.1.1 environment, filesystem 0 128 kB oss-bot
npm/yargs@17.7.2 environment, filesystem 0 292 kB oss-bot
npm/zustand@4.5.6 environment 0 326 kB daishi

🚮 Removed packages: npm/@eslint-community/regexpp@4.6.2, npm/@eslint/eslintrc@2.1.1, npm/@eslint/js@8.46.0, npm/@getalby/bitcoin-connect-react@3.3.0-beta.3, npm/@humanwhocodes/config-array@0.11.10, npm/@humanwhocodes/object-schema@1.2.1, npm/@swc/core-darwin-arm64@1.3.74, npm/@swc/core-darwin-x64@1.3.74, npm/@swc/core-linux-arm-gnueabihf@1.3.74, npm/@swc/core-linux-arm64-gnu@1.3.74, npm/@swc/core-linux-arm64-musl@1.3.74, npm/@swc/core-linux-x64-gnu@1.3.74, npm/@swc/core-linux-x64-musl@1.3.74, npm/@swc/core-win32-arm64-msvc@1.3.74, npm/@swc/core-win32-ia32-msvc@1.3.74, npm/@swc/core-win32-x64-msvc@1.3.74, npm/@swc/core@1.3.74, npm/@types/cookie@0.6.0, npm/@types/json-schema@7.0.12, npm/@types/react-dom@18.2.7, npm/@types/react@18.2.18, npm/@types/semver@7.5.0, npm/@typescript-eslint/eslint-plugin@6.2.1, npm/@typescript-eslint/parser@6.2.1, npm/@typescript-eslint/scope-manager@6.2.1, npm/@typescript-eslint/type-utils@6.2.1, npm/@typescript-eslint/types@6.2.1, npm/@typescript-eslint/typescript-estree@6.2.1, npm/@typescript-eslint/utils@6.2.1, npm/@typescript-eslint/visitor-keys@6.2.1, npm/@vitejs/plugin-react-swc@3.3.2, npm/@webbtc/webln-types@1.0.13, npm/cookie@1.0.2, npm/emittery@1.0.3, npm/eslint-plugin-react-refresh@0.4.3, npm/eslint@8.46.0, npm/fast-glob@3.3.1, npm/flat-cache@3.0.4, npm/flatted@3.2.7, npm/globals@13.20.0, npm/goober@2.1.13, npm/ignore@5.2.4, npm/natural-compare-lite@1.4.0, npm/punycode@2.3.0, npm/react-hot-toast@2.4.1, npm/react-router-dom@7.1.5, npm/react-router@7.1.5, npm/set-cookie-parser@2.7.1, npm/ts-api-utils@1.0.1, npm/turbo-stream@2.4.0

View full report↗︎

@rolznz rolznz merged commit f23a5a9 into master Mar 3, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for NWA (V2) and NWC deeplink flows

3 participants