-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Description
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:
-
Incorrect type definition — The
RequestMethodstype mapsgetAccountAddressestoRequest<undefined, string[]>, meaning the params type isundefined. It should beRequest<WCGetAccountAddressesParams, WCGetAccountAddressesResponse>withaccount(required) andintentions(optional). -
Missing
accountin call site — The method body never callsthis.getAccount(true)to resolve the connected account address, unlikesendTransferandsignPsbt.
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.