From 81f1b39aa81e0a7b9962355e88c6564e4bc32f2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ben=20Kn=C3=A1b?= Date: Sun, 2 Jun 2024 14:59:17 +0200 Subject: [PATCH 1/2] Add types for createFundedPsbt --- lnd_methods/onchain/create_funded_psbt.d.ts | 50 +++++++++++++++++++++ lnd_methods/onchain/index.d.ts | 1 + 2 files changed, 51 insertions(+) create mode 100644 lnd_methods/onchain/create_funded_psbt.d.ts diff --git a/lnd_methods/onchain/create_funded_psbt.d.ts b/lnd_methods/onchain/create_funded_psbt.d.ts new file mode 100644 index 0000000..d27df4e --- /dev/null +++ b/lnd_methods/onchain/create_funded_psbt.d.ts @@ -0,0 +1,50 @@ +import type { + AuthenticatedLightningArgs, + AuthenticatedLightningMethod, +} from '../../typescript'; + +export type CreateFundedPsbtArgs = AuthenticatedLightningArgs<{ + /** Chain Fee Tokens Per Virtual Byte Number */ + fee_tokens_per_vbyte?: number; + inputs?: Array<{ + /** Sequence Number */ + sequence?: number; + /** Unspent Transaction Id Hex String */ + transaction_id: string; + /** Unspent Transaction Output Index Number */ + transaction_vout: number; + }>; + /** Select Inputs With Minimum Confirmations Number */ + min_confirmations?: number; + outputs?: Array<{ + /** Use This Output For Change Bool */ + is_change?: boolean; + /** Output Script Hex String> */ + script: string; + /** Send Tokens Tokens Number */ + tokens: number; + }>; + /** Blocks To Wait for Confirmation Number */ + target_confirmations?: number; + /** Spendable Lock Time on Transaction Number */ + timelock?: number; + /** Select Inputs Using Selection Methodology Type String */ + utxo_selection?: string; + /** Transaction Version Number */ + version?: number; +}>; + +/** + * Create an unsigned funded PSBT given inputs or outputs + * + * When specifying local inputs, they must be locked before using + * + * `utxo_selection` methods: 'largest', 'random' + * + * Requires `onchain:write` permission + * + * Requires LND built with `walletrpc` tag + * + * This method is not supported on LND 0.17.5 or below + */ +export const createFundedPsbt: AuthenticatedLightningMethod; diff --git a/lnd_methods/onchain/index.d.ts b/lnd_methods/onchain/index.d.ts index 74e4eff..233f8de 100644 --- a/lnd_methods/onchain/index.d.ts +++ b/lnd_methods/onchain/index.d.ts @@ -1,6 +1,7 @@ export * from './broadcast_chain_transaction'; export * from './cancel_pending_channel'; export * from './close_channel'; +export * from './create_funded_psbt'; export * from './delete_chain_transaction'; export * from './fund_pending_channels'; export * from './fund_psbt'; From bfc16ff9ecba44170794499f56ade19396a2db8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ben=20Kn=C3=A1b?= Date: Sun, 2 Jun 2024 15:00:21 +0200 Subject: [PATCH 2/2] Add result type --- lnd_methods/onchain/create_funded_psbt.d.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lnd_methods/onchain/create_funded_psbt.d.ts b/lnd_methods/onchain/create_funded_psbt.d.ts index d27df4e..11d9d8b 100644 --- a/lnd_methods/onchain/create_funded_psbt.d.ts +++ b/lnd_methods/onchain/create_funded_psbt.d.ts @@ -34,6 +34,11 @@ export type CreateFundedPsbtArgs = AuthenticatedLightningArgs<{ version?: number; }>; +export interface CreateFundedPsbtResult { + /** Unsigned PSBT Hex String */ + psbt: string; +} + /** * Create an unsigned funded PSBT given inputs or outputs * @@ -47,4 +52,7 @@ export type CreateFundedPsbtArgs = AuthenticatedLightningArgs<{ * * This method is not supported on LND 0.17.5 or below */ -export const createFundedPsbt: AuthenticatedLightningMethod; +export const createFundedPsbt: AuthenticatedLightningMethod< + CreateFundedPsbtArgs, + CreateFundedPsbtResult +>;