-
Notifications
You must be signed in to change notification settings - Fork 302
feat: add isWalletAddress endpoint #7626
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
19e2f44
feat: add isWalletAddress endpoint
danielzhao122 04f0196
docs: include that custodial wallets address is not supported
danielzhao122 fe01aef
docs: include some more details on how to retrieve certain values
danielzhao122 4c86891
feat: add example scripts
danielzhao122 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 102 additions & 0 deletions
102
modules/express/src/typedRoutes/api/v2/isWalletAddress.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| import * as t from 'io-ts'; | ||
| import { httpRoute, httpRequest, optional } from '@api-ts/io-ts-http'; | ||
| import { BitgoExpressError } from '../../schemas/error'; | ||
|
|
||
| /** | ||
| * Path parameters for verifying if an address belongs to a wallet | ||
| */ | ||
| export const IsWalletAddressParams = { | ||
| /** Coin ticker / chain identifier */ | ||
| coin: t.string, | ||
| /** The ID of the wallet */ | ||
| id: t.string, | ||
| } as const; | ||
|
|
||
| /** | ||
| * Keychain codec for address verification | ||
| * Supports both BIP32 wallets (need ethAddress) and TSS/MPC wallets (need commonKeychain) | ||
| */ | ||
| export const KeychainCodec = t.intersection([ | ||
| // Required field | ||
| t.type({ | ||
| pub: t.string, | ||
| }), | ||
| // Optional fields for different wallet types | ||
| t.partial({ | ||
| /** Ethereum address (required for BIP32 wallet base address verification: V1, V2, V4) */ | ||
| ethAddress: t.string, | ||
| /** Common keychain (required for TSS/MPC wallets: V3, V5, V6) */ | ||
| commonKeychain: t.string, | ||
| }), | ||
| ]); | ||
|
|
||
| /** | ||
| * Request body for verifying if an address belongs to a wallet | ||
| */ | ||
| export const IsWalletAddressBody = { | ||
| /** The address to verify */ | ||
| address: t.string, | ||
| /** Keychains for verification */ | ||
| keychains: t.array(KeychainCodec), | ||
| /** Base address of the wallet */ | ||
| baseAddress: optional(t.string), | ||
| /** Wallet version */ | ||
| walletVersion: optional(t.number), | ||
| /** Address index for TSS/MPC wallet derivation */ | ||
| index: optional(t.union([t.number, t.string])), | ||
| /** Coin-specific address data */ | ||
| coinSpecific: optional( | ||
| t.partial({ | ||
| /** Forwarder version */ | ||
| forwarderVersion: t.number, | ||
| /** Salt for CREATE2 address derivation */ | ||
| salt: t.string, | ||
| /** Fee address for v4 forwarders */ | ||
| feeAddress: t.string, | ||
| /** Base address (alternative to top-level baseAddress) */ | ||
| baseAddress: t.string, | ||
| }) | ||
| ), | ||
| /** Implied forwarder version */ | ||
| impliedForwarderVersion: optional(t.number), | ||
| /** Format for the address */ | ||
| format: optional(t.string), | ||
| /** Root address for coins that use root address */ | ||
| rootAddress: optional(t.string), | ||
|
danielzhao122 marked this conversation as resolved.
danielzhao122 marked this conversation as resolved.
|
||
| } as const; | ||
|
|
||
| /** | ||
| * Response for verifying if an address belongs to a wallet | ||
| */ | ||
| export const IsWalletAddressResponse = { | ||
| 200: t.boolean, | ||
| 400: BitgoExpressError, | ||
| } as const; | ||
|
|
||
| /** | ||
| * Verify if an address belongs to a wallet | ||
| * | ||
| * This endpoint verifies whether a given address belongs to the specified wallet. | ||
| * It performs cryptographic verification, checking address derivation | ||
| * against wallet keychains and configuration. | ||
| * | ||
| * Returns `true` if the address belongs to the wallet, `false` otherwise. | ||
| * Throws an error if verification fails or parameters are invalid. | ||
| * | ||
| * To verify a baseAddress, set the `baseAddress` and `address` to the base address of the wallet. | ||
| * | ||
| * Due to architecture limitations, forwarder version 0 addresses cannot be verified and will return `true` without verification. | ||
| * Verifying custodial wallet addresses is not supported. | ||
| * | ||
| * @operationId express.v2.wallet.isWalletAddress | ||
| * @tag Express | ||
| */ | ||
| export const PostIsWalletAddress = httpRoute({ | ||
| path: '/api/v2/{coin}/wallet/{id}/iswalletaddress', | ||
| method: 'POST', | ||
| request: httpRequest({ | ||
| params: IsWalletAddressParams, | ||
| body: IsWalletAddressBody, | ||
| }), | ||
| response: IsWalletAddressResponse, | ||
| }); | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.