@xchainjs/xchain-dash 2.0.9 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/client.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { AssetInfo, FeeRate, TxHistoryParams } from '@xchainjs/xchain-client';
2
2
  import { Address } from '@xchainjs/xchain-util';
3
- import { Balance, Client as UTXOClient, Tx, TxParams, TxsPage, UTXO, UtxoClientParams } from '@xchainjs/xchain-utxo';
3
+ import { Balance, Client as UTXOClient, PreparedTx, Tx, TxParams, TxsPage, UTXO, UtxoClientParams, UtxoSelectionPreferences } from '@xchainjs/xchain-utxo';
4
4
  import { DashPreparedTx, NodeAuth, NodeUrls } from './types';
5
5
  /**
6
6
  * Default parameters for the DASH client.
@@ -59,6 +59,7 @@ declare abstract class Client extends UTXOClient {
59
59
  private insightTxToXChainTx;
60
60
  /**
61
61
  * Asynchronously prepares a transaction for sending assets.
62
+ * @deprecated Use `prepareTxEnhanced` instead for better UTXO selection and error handling.
62
63
  * @param {TxParams&Address&FeeRate} params - Parameters for the transaction preparation.
63
64
  * @returns {string} A promise resolving to the prepared transaction data.
64
65
  */
@@ -80,5 +81,29 @@ declare abstract class Client extends UTXOClient {
80
81
  * @returns {number} The calculated transaction fee amount.
81
82
  */
82
83
  protected getFeeFromUtxos(inputs: UTXO[], feeRate: FeeRate, data?: Buffer | null): number;
84
+ /**
85
+ * Prepare transaction with enhanced UTXO selection.
86
+ * Uses base class UTXO selection logic with dashcore-lib transaction building.
87
+ */
88
+ prepareTxEnhanced({ sender, memo, amount, recipient, feeRate, spendPendingUTXO, utxoSelectionPreferences, }: TxParams & {
89
+ sender: Address;
90
+ feeRate: FeeRate;
91
+ spendPendingUTXO?: boolean;
92
+ utxoSelectionPreferences?: UtxoSelectionPreferences;
93
+ }): Promise<PreparedTx>;
94
+ /**
95
+ * Prepare max send transaction
96
+ */
97
+ prepareMaxTx({ sender, recipient, memo, feeRate, spendPendingUTXO, utxoSelectionPreferences, }: {
98
+ sender: Address;
99
+ recipient: Address;
100
+ memo?: string;
101
+ feeRate: FeeRate;
102
+ spendPendingUTXO?: boolean;
103
+ utxoSelectionPreferences?: UtxoSelectionPreferences;
104
+ }): Promise<PreparedTx & {
105
+ maxAmount: number;
106
+ fee: number;
107
+ }>;
83
108
  }
84
109
  export { Client };
@@ -1,6 +1,6 @@
1
1
  import { FeeRate, TxHash } from '@xchainjs/xchain-client';
2
2
  import { Address } from '@xchainjs/xchain-util';
3
- import { TxParams } from '@xchainjs/xchain-utxo';
3
+ import { TxParams, UtxoSelectionPreferences } from '@xchainjs/xchain-utxo';
4
4
  import { ECPairInterface } from 'ecpair';
5
5
  import { Client } from './client';
6
6
  export declare class ClientKeystore extends Client {
@@ -30,10 +30,34 @@ export declare class ClientKeystore extends Client {
30
30
  getDashKeys(phrase: string, index?: number): ECPairInterface;
31
31
  /**
32
32
  * Asynchronously transfers assets between addresses.
33
- * @param {TxParams & { feeRate?: FeeRate }} params - Parameters for the transfer.
33
+ * @param {TxParams & { feeRate?: FeeRate; utxoSelectionPreferences?: UtxoSelectionPreferences }} params - Parameters for the transfer.
34
34
  * @returns {Promise<TxHash>} A promise resolving to the transaction hash.
35
35
  */
36
36
  transfer(params: TxParams & {
37
37
  feeRate?: FeeRate;
38
+ utxoSelectionPreferences?: UtxoSelectionPreferences;
38
39
  }): Promise<TxHash>;
40
+ /**
41
+ * Transfer the maximum amount of DASH (sweep).
42
+ *
43
+ * Calculates the maximum sendable amount after fees, signs, and broadcasts the transaction.
44
+ * @param {Object} params The transfer parameters.
45
+ * @param {string} params.recipient The recipient address.
46
+ * @param {string} [params.memo] Optional memo for the transaction.
47
+ * @param {FeeRate} [params.feeRate] Optional fee rate. Defaults to 'average' rate.
48
+ * @param {number} [params.walletIndex] Optional wallet index. Defaults to 0.
49
+ * @param {UtxoSelectionPreferences} [params.utxoSelectionPreferences] Optional UTXO selection preferences.
50
+ * @returns {Promise<{ hash: TxHash; maxAmount: number; fee: number }>} The transaction hash, amount sent, and fee.
51
+ */
52
+ transferMax(params: {
53
+ recipient: Address;
54
+ memo?: string;
55
+ feeRate?: FeeRate;
56
+ walletIndex?: number;
57
+ utxoSelectionPreferences?: UtxoSelectionPreferences;
58
+ }): Promise<{
59
+ hash: TxHash;
60
+ maxAmount: number;
61
+ fee: number;
62
+ }>;
39
63
  }