From 4a3b6810a5f6d9357bab95b010445f273e3dab1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eduard=20Bardaj=C3=AD=20Puig?= Date: Thu, 3 Oct 2024 20:04:45 +0100 Subject: [PATCH] Add types --- src/request/types/btcMethods.ts | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/src/request/types/btcMethods.ts b/src/request/types/btcMethods.ts index bad13f8..113efb0 100644 --- a/src/request/types/btcMethods.ts +++ b/src/request/types/btcMethods.ts @@ -141,20 +141,35 @@ type Recipient = { amount: number; }; -export type SendTransferParams = { +export const sendTransferMethodName = 'sendTransfer'; +export const sendTransferParamsSchema = v.object({ /** * Array of recipients to send to. * The amount to send to each recipient is in satoshis. */ - recipients: Array; -}; -type SendTransferResult = { + recipients: v.array( + v.object({ + address: v.string(), + amount: v.number(), + }) + ), +}); +export type SendTransferParams = v.InferOutput; +export const sendTransferResultSchema = v.object({ /** * The transaction id as a hex-encoded string. */ - txid: string; -}; - + txid: v.string(), +}); +export type SendTransferResult = v.InferOutput; +export const sendTransferRequestMessageSchema = v.object({ + ...rpcRequestMessageSchema.entries, + ...v.object({ + method: v.literal(sendTransferMethodName), + params: sendTransferParamsSchema, + id: v.string(), + }).entries, +}); export type SendTransfer = MethodParamsAndResult; export type SignPsbtParams = {