Skip to content

Mismatch getAccountAddresses sends undefined params instead of required account field #5590

@Justkant

Description

@Justkant

Bug Description

The BitcoinWalletConnectConnector.getAccountAddresses() method sends params: undefined in the WalletConnect request, but the BIP122 getAccountAddresses RPC specification defines account as a required parameter.

Expected Behavior

Per the spec, the request should include the connected account's first external address:

{
    "method": "getAccountAddresses",
    "params": {
        "account": "bc1qcr8te4kr609gcawutmrza0j4xv80jy8z306fyu"
    }
}

Actual Behavior

The connector sends:

{
    "method": "getAccountAddresses",
    "params": undefined
}

This is because BitcoinWalletConnectConnector.ts line 83-86 hardcodes params: undefined:

const addresses = await this.internalRequest({
  method: 'getAccountAddresses',
  params: undefined
})

Other methods in the same file (sendTransfer, signPsbt) correctly call this.getAccount(true) and pass the result as params.account. The getAccountAddresses method should do the same.

Root Cause

Two issues in the type/implementation:

  1. Incorrect type definition — The RequestMethods type maps getAccountAddresses to Request<undefined, string[]>, meaning the params type is undefined. It should be Request<WCGetAccountAddressesParams, WCGetAccountAddressesResponse> with account (required) and intentions (optional).

  2. Missing account in call site — The method body never calls this.getAccount(true) to resolve the connected account address, unlike sendTransfer and signPsbt.

Suggested Fix

// 1. Add a params type
export type WCGetAccountAddressesParams = {
  account: string
  intentions?: string[]
}

// 2. Fix the RequestMethods mapping
getAccountAddresses: Request<WCGetAccountAddressesParams, WCGetAccountAddressesResponse>

// 3. Fix the method implementation
public async getAccountAddresses(): Promise<BitcoinConnector.AccountAddress[]> {
  this.checkIfMethodIsSupported('getAccountAddresses')
  const account = this.getAccount(true)

  const addresses = await this.internalRequest({
    method: 'getAccountAddresses',
    params: { account }
  })

  return addresses.map(address => ({ address, purpose: AddressPurpose.Payment }))
}

Impact

Wallet implementations that strictly validate the required account param (as the spec mandates) will reject getAccountAddresses requests coming from appkit dapps. This breaks balance fetching and UTXO discovery for Bitcoin dapps using WalletConnect.

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions