Skip to content

Add BIP49 support for Liquid wallets (Aqua compatibility)#1381

Open
echennells wants to merge 1 commit into
SatoshiPortal:developfrom
echennells:feature/aqua-bip49-clean
Open

Add BIP49 support for Liquid wallets (Aqua compatibility)#1381
echennells wants to merge 1 commit into
SatoshiPortal:developfrom
echennells:feature/aqua-bip49-clean

Conversation

@echennells
Copy link
Copy Markdown

Summary

Adds BIP49 (nested SegWit) support for Liquid wallets to enable automatic recovery of Aqua wallet funds.

When importing/recovering a wallet, the system now automatically detects whether the user has legacy BIP49 Liquid funds (Aqua compatibility) or should use the newer BIP84 (native SegWit) standard.

Dependencies

Requires lwk-dart PR #66 for BIP49 support: SatoshiPortal/lwk-dart#66

Pubspec files are intentionally excluded from this PR. Reviewers will need to configure local dependencies to point to lwk-dart PR #66 for testing.

Network Requirement:

BIP49 detection requires network connectivity during wallet import to check on-chain balances. This adds latency on slow networks (5-30 seconds tested with Network Link
Conditioner).

Key Changes

  • Created DetectLiquidScriptTypeUsecase to centralize BIP49 detection logic
  • Automatically checks for BIP49 funds during wallet recovery
  • Falls back to BIP84 if no BIP49 funds detected
  • Added BIP49 (P2SH-P2WPKH) script variant support for Liquid descriptors
  • Fixed bug in import wallet flow where sync was disabled during detection

Related Work

PR #1376 fixed the import wallet flow to properly sync existing Liquid wallets. This PR extends that functionality to also auto-detect and support BIP49 Liquid wallets (Aqua compatibility).

  Implements automatic BIP49 vs BIP84 detection during wallet recovery
  for backward compatibility with Aqua wallet.

  - Create DetectLiquidScriptTypeUsecase to centralize detection logic
  - Check BIP49 balance during recovery, fall back to BIP84 if empty
  - Add BIP49 (P2SH-P2WPKH) script variant for Liquid descriptors
  - Fix import wallet sync bug

  Detection requires network sync to check on-chain balance.
@i5hi
Copy link
Copy Markdown
Collaborator

i5hi commented Oct 28, 2025

Hey @echennells thanks for the PR.
We don't want to support using the nested segwit wallet in BULL (or multiple liquid wallets - this change will be involved because in several parts of the app we assume only 1 liquid wallet).

To support import of Aqua wallets what is preferable is detecting the funds in the bip49 path and asking the user if they want to sweep it into the default segwit wallet.

@BullishNode
Copy link
Copy Markdown
Contributor

Why not just get Aqua to support Segwit instead?

@echennells
Copy link
Copy Markdown
Author

echennells commented Oct 28, 2025

@i5hi @BullishNode Okay understood I know its a bit wonky especially because the wallet needs to be synced to check for balances.

Would you be interested in an import and sweep that isn't part of the main wallet creation workflow? Essentially a migration utility which would help people sweep their funds.

Interestingly it seems like aqua wrote sweep code but never enabled it in their app so right now there is no easy workflow for people switching from aqua to bull.

@basantagoswami
Copy link
Copy Markdown
Contributor

@echennells what we can do is show a popup on the wallet home screen that opens up a modal or screen where they have to confirm the sweep. it can be a popup similar to the one users see when they receive funds to their wallet, but haven't started the backup process yet

it'll show something like you have n sats in a unsupported wallet, would you like to swap the balance to your instant payment wallet?

@echennells
Copy link
Copy Markdown
Author

@basantagoswami I just want to confirm what workflow are you suggesting. On import of a wallet there would be detection of a BIP49 (legacy) wallet and have a pop up giving the option to sweep it?

Sweep to where? I guess that implies it needs to create a new wallet as part of the sweep flow.

I'll give that a shot please give me more feedback if I'm misunderstanding;

@BullishNode
Copy link
Copy Markdown
Contributor

The BIP49 seed should only be imported after the wallet is created and swept to the default Liquid wallet IMO (not at app install).

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.

4 participants