|
| 1 | +import * as t from 'io-ts'; |
| 2 | +import { httpRoute, httpRequest, optional } from '@api-ts/io-ts-http'; |
| 3 | +import { BitgoExpressError } from '../../schemas/error'; |
| 4 | + |
| 5 | +/** |
| 6 | + * Path parameters for coin-specific address verification. |
| 7 | + * @property coin - Ticker or identifier of the coin (e.g. 'btc', 'eth'). |
| 8 | + */ |
| 9 | +export const VerifyAddressV2Params = { |
| 10 | + /** Coin ticker / chain identifier */ |
| 11 | + coin: t.string, |
| 12 | +}; |
| 13 | + |
| 14 | +/** |
| 15 | + * Request body for coin-specific address verification. |
| 16 | + * |
| 17 | + * @property address - The address string to validate. |
| 18 | + * @property supportOldScriptHashVersion - (UTXO only) When true, treat legacy script hash version as acceptable. |
| 19 | + */ |
| 20 | +export const VerifyAddressV2Body = { |
| 21 | + /** Address to be validated */ |
| 22 | + address: t.string, |
| 23 | + /** Accept legacy script hash version for applicable UTXO coins (optional). */ |
| 24 | + supportOldScriptHashVersion: optional(t.boolean), |
| 25 | +}; |
| 26 | + |
| 27 | +/** |
| 28 | + * Verify address for a given coin. |
| 29 | + * |
| 30 | + * Returns whether the address is valid for the specified coin. |
| 31 | + * For UTXO coins, an optional legacy script hash flag can be provided to allow previous script hash versions. |
| 32 | + * |
| 33 | + * @operationId express.verifycoinaddress |
| 34 | + */ |
| 35 | +export const PostVerifyCoinAddress = httpRoute({ |
| 36 | + path: '/api/v2/{coin}/verifyaddress', |
| 37 | + method: 'POST', |
| 38 | + request: httpRequest({ |
| 39 | + params: VerifyAddressV2Params, |
| 40 | + body: VerifyAddressV2Body, |
| 41 | + }), |
| 42 | + response: { |
| 43 | + 200: t.type({ |
| 44 | + isValid: t.boolean, |
| 45 | + }), |
| 46 | + 404: BitgoExpressError, |
| 47 | + }, |
| 48 | +}); |
0 commit comments