Skip to content

feat: support all address types#431

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

feat: support all address types#431
ben-kaufman wants to merge 24 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 ben-kaufman requested a review from ovitrif February 5, 2026 11:13
@claude

This comment has been minimized.

@ben-kaufman ben-kaufman force-pushed the feat/multiple-addresses-types branch from 919e450 to 8c8e243 Compare February 11, 2026 04:38
@claude

This comment has been minimized.

@claude

This comment has been minimized.

@claude

This comment has been minimized.

@claude

This comment has been minimized.

@claude

This comment has been minimized.

@claude

This comment has been minimized.

@jvsena42
Copy link
Member

@claude create a checklist of manual test flows

@claude

This comment has been minimized.

@ben-kaufman ben-kaufman force-pushed the feat/multiple-addresses-types branch from 1170e77 to b0e40c3 Compare February 16, 2026 14:11
@ovitrif ovitrif changed the title Support all address types feat: support all address types Feb 16, 2026
Copy link
Collaborator

@ovitrif ovitrif left a comment

Choose a reason for hiding this comment

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

Test 1

Ran successfully the 1st pass of tests: switching and receiving to each address type as configurable in settings.


@ben-kaufman
I noticed the Address Viewer only knows the native segwit address type. Maybe worth updating it with implementation matching the former react native functionality which allowed switching address type on that screen. Probably best done on another PR to keep the changes reviewable; can be stacked PR, targeting the branch of this one.

@ben-kaufman
Copy link
Contributor Author

@ovitrif I just updated the address viewer here since it was a very small change

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.

Didn't find any actual bug, just some suggestions

Still testing...

Comment on lines 1345 to 1351
private static func parseAddressType(_ string: String?) -> LDKNode.AddressType {
switch string {
case "legacy": return .legacy
case "nestedSegwit": return .nestedSegwit
case "taproot": return .taproot
default: return .nativeSegwit
}
Copy link
Member

Choose a reason for hiding this comment

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

do {
let newAddress = try await lightningService.newAddressForType(addressType)

UserDefaults.standard.set(newAddress, forKey: "onchainAddress")
Copy link
Member

Choose a reason for hiding this comment

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

nit could check defensively if the address matches the addressType before saving it and even add unit tests

@ben-kaufman ben-kaufman force-pushed the feat/multiple-addresses-types branch from 21fca73 to dc1ab2a Compare February 18, 2026 05:44
@ben-kaufman
Copy link
Contributor Author

@jvsena42 updated for all comments

@ovitrif ovitrif self-requested a review February 18, 2026 07:49
Co-authored-by: João Victor Sena <jvsena42@users.noreply.github.com>
@jvsena42
Copy link
Member

I didn't know that Claude would automatically commit 😶‍🌫️

currentWalletAddress: String,
selectedAddressType: LDKNode.AddressType
) async throws -> String? {
guard !isSearching else { return nil }
Copy link
Member

@jvsena42 jvsena42 Feb 18, 2026

Choose a reason for hiding this comment

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

could enqueue instead of returning nil, to reduce the risk of returning a wrong address in this fallback, or at least log this with a warning

Copy link
Member

Choose a reason for hiding this comment

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

but enqueue could also make the sync slower

Comment on lines +88 to +90
let monitoredTypes = monitoredTypesString.split(separator: ",")
.map { String($0).trimmingCharacters(in: .whitespaces) }
.compactMap { LDKNode.AddressType.from(string: $0) }
Copy link
Member

Choose a reason for hiding this comment

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

this logic is also duplicated, could move it to LDKNode.AddressType

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.

3 participants