From 599959760fcb7c6bbe657134c058db469d883c77 Mon Sep 17 00:00:00 2001 From: kyranjamie Date: Sat, 27 Jul 2024 13:39:28 +0200 Subject: [PATCH] fix(rpc): add stx public key, improve types --- packages/rpc/src/methods/get-addresses.ts | 26 +++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/packages/rpc/src/methods/get-addresses.ts b/packages/rpc/src/methods/get-addresses.ts index 95caf47e7..95b2a5465 100644 --- a/packages/rpc/src/methods/get-addresses.ts +++ b/packages/rpc/src/methods/get-addresses.ts @@ -4,13 +4,35 @@ import { DefineRpcMethod, RpcRequest, RpcResponse } from '../rpc'; export type PaymentTypes = 'p2pkh' | 'p2sh' | 'p2wpkh-p2sh' | 'p2wpkh' | 'p2tr'; -export interface BtcAddress extends AllowAdditionalProperties { +export interface BtcAddressBase extends AllowAdditionalProperties { + symbol: 'BTC'; type: PaymentTypes; address: string; + publicKey: string; + derivationPath: string; } +export interface NativeSegwitAddress extends BtcAddressBase { + type: 'p2wpkh'; +} + +export interface TaprootAddress extends BtcAddressBase { + type: 'p2tr'; + tweakedPublicKey: string; +} + +type BtcAddress = NativeSegwitAddress | TaprootAddress; + +export interface StxAddress extends AllowAdditionalProperties { + symbol: 'STX'; + address: string; + publicKey: string; +} + +type Address = BtcAddress | StxAddress; + export interface AddressResponseBody extends AllowAdditionalProperties { - addresses: BtcAddress[]; + addresses: Address[]; } export type GetAddressesRequest = RpcRequest<'getAddresses'>;