Skip to content

feat: support all address types#788

Open
ben-kaufman wants to merge 41 commits intomasterfrom
feat/multiple-addresses-types
Open

feat: support all address types#788
ben-kaufman wants to merge 41 commits intomasterfrom
feat/multiple-addresses-types

Conversation

@ben-kaufman
Copy link
Contributor

This PR adds support for multiple Bitcoin address types in the iOS app, allowing users to select and monitor different address formats. Users can select their preferred address type from: Legacy (P2PKH), Nested SegWit (P2SH-P2WPKH), Native SegWit (P2WPKH), and Taproot (P2TR).

This requires extensive testing across all functionalities, send, receive, channel open, channel close (funds should always go to native segwit address except when selected address when channel opened was Taproot, in which case it should be a Taproot address), cpfp, rbf. All should be checked for each address type, and for multiple address types combined (ie. send with utxos of different address types, open channel with inputs of different address types, boost txs with inputs of different address types, etc.)

@ben-kaufman
Copy link
Contributor Author

@piotr-iohk one test in the e2e suite is failing, but looking at the video it actually seems correct. The amount left is indeed not dust, so it seems like current behaviour is ok, maybe something in the test should bbe updated like setting the fee rate to ensure amount left will necessarily be dust?

@ben-kaufman ben-kaufman force-pushed the feat/multiple-addresses-types branch from b88692e to 8738aeb Compare February 18, 2026 08:52
@jvsena42
Copy link
Member

Review in progress ...

@piotr-iohk
Copy link
Collaborator

Seeing this randomly. The scenario is as follows:

  • change the address type and fund it with 25k sats so I have 100k in total (in sequence: Legacy, Nested Segwit, Native Service, Taproot)
  • after each tx the block is minted, so each tx is confirmed.
  • then transfer to spending using max amount -> getting the toast error. (On-chain transaction could not be created)
  • note that on the next attempt the transfer is successful.

logs.zip

Screen.Recording.2026-02-26.at.12.05.49.mov

@piotr-iohk
Copy link
Collaborator

Small issue, "Settings updated" toast on android differs from the iOS one which has bit more details. Perhaps should be unified. (iOS left / Android right)

Screen.Recording.2026-02-26.at.12.30.24.mov

@piotr-iohk
Copy link
Collaborator

@piotr-iohk couldn't reproduce but made a small fix and added logs which should help understand the issue if it happens again

Probably a false negative on isMaxAmount

I wasn't able to reproduce. There is a stacked PR running all e2e tests: #820.

For now change address check disabled in the tests. Waiting for synonymdev/ldk-node#72.

@jvsena42

This comment was marked as resolved.

Copy link
Member

@jvsena42 jvsena42 left a comment

Choose a reason for hiding this comment

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

1. Address Type Selection & Settings

Initial Setup

  • Fresh wallet creation - verify default address type is Native SegWit
  • Navigate to Settings → Advanced → Address Type Preference
  • Verify all 4 address types are displayed with correct labels:
    • Legacy (1x...)
    • Nested SegWit (3x...)
    • Native SegWit (bc1q...)
    • Taproot (bc1p...)

Switching Address Types

  • Switch from Native SegWit to Legacy - verify success toast
  • Verify receive address changes to Legacy format (starts with "m" for regtest)
  • Switch to Nested SegWit - verify address starts with "2" for regtest
  • Switch to Taproot - verify address starts with "bcrt1p" for regtest
  • Switch back to Native SegWit - verify address starts with "bcrt1q" for regtest

Monitored Address Types (Dev Settings)

  • Enable dev settings and verify "Monitored Address Types" section appears
  • Enable monitoring for Legacy while Native SegWit is selected
  • Enable monitoring for Taproot while Native SegWit is selected
  • Verify cannot disable currently selected address type
  • Verify cannot disable last native witness type (Native SegWit or Taproot)
  • Add funds to a monitored type, then try to disable it - should fail

2. Receive Functionality

Address QR Codes

  • Generate QR code for each address type
  • Verify QR code contains correct address format
  • Test scanning generated QR codes

Multiple Address Types (Mixed Wallet)

  • Set address type to Native SegWit, receive funds
  • Switch to Legacy, receive funds to new Legacy address
  • Switch to Taproot, receive funds to new Taproot address
  • Verify all balances are correctly aggregated in wallet total
  • Verify activity list shows all transactions

3. Send Functionality

Single Address Type Sends

  • Enable manual coin selection
  • Add tags to identify the address type
  • Legacy only: Send from wallet selecting only Legacy UTXOs
    • Verify fee estimation
    • Complete send and verify transaction
  • Nested SegWit only: Send from wallet selecting only Nested SegWit UTXOs
  • Native SegWit only: Send from wallet selecting only Native SegWit UTXOs
  • Taproot only: Send from wallet selecting only Taproot UTXOs

4. Lightning Channel Operations

Channel Opening

  • Legacy: Set address type to Legacy, open channel
    • Verify funding transaction uses Legacy inputs if available
  • Nested SegWit: Set to Nested SegWit, open channel
    • Verify funding transaction format
  • Native SegWit: Set to Native SegWit, open channel
  • Taproot: Set to Taproot, open channel
  • Mixed UTXOs: Open channel with inputs from multiple address types

5. Fee Bumping (RBF - Replace-By-Fee)

RBF Single Address Type

  • Send replaceable transaction from Legacy wallet, bump fee
  • Send replaceable transaction from Nested SegWit wallet, bump fee
  • Send replaceable transaction from Native SegWit wallet, bump fee
  • Send replaceable transaction from Taproot wallet, bump fee

RBF Mixed Address Types

  • Send transaction with all 4 address types, bump fee

6. CPFP (Child-Pays-For-Parent)

CPFP Single Address Type

  • Receive unconfirmed transaction to Legacy address, boost with CPFP
  • Receive unconfirmed transaction to Nested SegWit, boost with CPFP
  • Receive unconfirmed transaction to Native SegWit, boost with CPFP
  • Receive unconfirmed transaction to Taproot, boost with CPFP

7. Wallet Restore & Migration

Fresh Restore

  • Restore wallet with funds across all 4 address types
    • Verify all funds are discovered and aggregated correctly

Migration from React Native App

  • ❌ Verify address type migration handles properly (RN only allowed select taproot and native segwit) - #788 (comment)
  • Check monitored types are correctly configured after migration

8. Balance & Display

Balance Calculation

  • Verify total balance correctly sums all address types
  • Verify spendable balance is accurate with mixed UTXOs
  • Check balance per address type (dev settings)

Activity List

  • Verify transactions from all address types appear in activity list
  • Verify correct icons/labels for each address type transaction
  • Test filtering/sorting with mixed address type transactions

9. Edge Cases & Error Handling

Settings Validations

  • Try to disable all monitored types - should fail
  • Try to disable currently selected type - should fail
  • Try to disable last native witness type - should fail

10. Backup & Security

Backup Flows

  • Create backup after switching address types
  • Restore from backup - verify address type preferences are preserved
  • Verify seed phrase backup includes all address types

@piotr-iohk
Copy link
Collaborator

❌ The selected address type from RN is reseted to native-segwit after migration

Also monitor address types are disabled for the addresses that RN app had funds on.
Say I have in RN app:

  • funds on legacy, native segwit and nested segwit. and nested segwit active.

Expected after migration:

  • Should have nested segwit active
  • should have monitoring enabled for all addresses I have funds on. (otherwise there will be confusion about missing funds)

Actual:

  • I have native-segwit active
  • monitoring enabled only for native segwit.

@ben-kaufman
Copy link
Contributor Author

@piotr-iohk does it happen with latest commit still?

@piotr-iohk
Copy link
Collaborator

@piotr-iohk does it happen with latest commit still?

Looking good now. iOS looking good also, btw.

- { name: migration_1-restore, grep: "@migration_1" }
- { name: migration_2-migration, grep: "@migration_2" }
- { name: migration_3-with-passphrase, grep: "@migration_3" }
- { name: migration_4-with-sweep, grep: "@migration_4" }
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not needed, migration tests updated in related e2e branch.

piotr-iohk
piotr-iohk previously approved these changes Mar 4, 2026
Copy link
Collaborator

@piotr-iohk piotr-iohk left a comment

Choose a reason for hiding this comment

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

LGTM

jvsena42
jvsena42 previously approved these changes Mar 4, 2026
Copy link
Member

@jvsena42 jvsena42 left a comment

Choose a reason for hiding this comment

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

Retested last failed scenario

test: split android e2e local and regtest (e2e multiple address)
@ovitrif ovitrif dismissed stale reviews from jvsena42 and piotr-iohk via aad545d March 4, 2026 22:28
# Conflicts:
#	app/src/main/java/to/bitkit/services/MigrationService.kt
@ovitrif
Copy link
Collaborator

ovitrif commented Mar 4, 2026

Had to fix merge manually after #813 got merged in the meantime and merged #820 after approval

Need a re-approval from @jvsena42 and/or @piotr-iohk to be able to merge 🙏🏻

ldk-node rc.31 was deleted and re-created so it includes now the latest fix by @ben-kaufman

Had to bump version because rc.31 was already cached by gradle task in actions workflows and won't re=download. So rc.32 is getting into master via:

piotr-iohk
piotr-iohk previously approved these changes Mar 5, 2026
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