Skip to content

Commit

Permalink
Fix incorrect address reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
swansontec committed Jan 3, 2025
1 parent eabfa64 commit b5ccc96
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Unreleased

- deprecated: `EdgeCurrencyWallet.denominationToNative` and `EdgeCurrencyWallet.nativeToDenomination` utilities. Clients can perform these conversions on their own, using information that the core already provides.
- fixed: Do not report the `segwitAddress` as the `publicAddress` for wallets that have one.

## 2.22.1 (2024-12-17)

Expand Down
10 changes: 8 additions & 2 deletions src/core/currency/wallet/currency-wallet-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -441,10 +441,16 @@ export function makeCurrencyWalletApi(
opts: EdgeGetReceiveAddressOptions
): Promise<EdgeReceiveAddress> {
const addresses = await this.getAddresses(opts)
if (addresses.length < 1) throw new Error('No addresses available')

const primaryAddress =
addresses.find(address => {
return address.addressType === 'publicAddress'
}) ?? addresses[0]

const receiveAddress: EdgeReceiveAddress = {
publicAddress: addresses[0].publicAddress,
nativeBalance: addresses[0].nativeBalance,
publicAddress: primaryAddress.publicAddress,
nativeBalance: primaryAddress.nativeBalance,
metadata: fakeMetadata,
nativeAmount: '0'
}
Expand Down
5 changes: 5 additions & 0 deletions src/types/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -698,6 +698,11 @@ export interface EdgeDataDump {
}
}

/**
* Addresses may appear in any order that the plugin chooses,
* based on how the user should see them. If you need a specific address type,
* use the `addressType` to find what you need.
*/
export interface EdgeAddress {
addressType: string // 'publicAddress' | 'segwitAddress' | 'legacyAddress' | 'fooAddress'
publicAddress: string
Expand Down

0 comments on commit b5ccc96

Please sign in to comment.