@gvnrdao/dh-sdk 0.0.287 → 0.0.288

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.
Files changed (76) hide show
  1. package/browser/dist/397.browser.js +2 -0
  2. package/browser/dist/397.browser.js.LICENSE.txt +1 -0
  3. package/browser/dist/833.browser.js +1 -1
  4. package/browser/dist/browser.js +1 -1
  5. package/browser/dist/browser.js.LICENSE.txt +10 -5
  6. package/dist/deployments.js +45 -21
  7. package/dist/deployments.mjs +45 -21
  8. package/dist/index.js +615 -1100
  9. package/dist/index.mjs +615 -1100
  10. package/package.json +1 -1
  11. package/dist/constants/chunks/contract-abis.d.ts +0 -20
  12. package/dist/constants/chunks/deployment-addresses.d.ts +0 -79
  13. package/dist/constants/chunks/encrypted-provider-params.d.ts +0 -21
  14. package/dist/constants/chunks/environment.browser.d.ts +0 -44
  15. package/dist/constants/chunks/environment.d.ts +0 -57
  16. package/dist/constants/chunks/network-configs.d.ts +0 -72
  17. package/dist/constants/chunks/sdk-config.d.ts +0 -33
  18. package/dist/constants/chunks/sdk-limits.d.ts +0 -66
  19. package/dist/constants/index.d.ts +0 -15
  20. package/dist/contracts/typechain-contracts/common.d.ts +0 -50
  21. package/dist/contracts/typechain-contracts/factories/src/psm/SimplePSMV2__factory.d.ts +0 -1996
  22. package/dist/contracts/typechain-contracts/src/psm/SimplePSMV2.d.ts +0 -1198
  23. package/dist/graphs/client.d.ts +0 -22
  24. package/dist/graphs/diamond-hands.d.ts +0 -259
  25. package/dist/index.d.ts +0 -56
  26. package/dist/interfaces/chunks/btc.i.d.ts +0 -36
  27. package/dist/interfaces/chunks/config.i.d.ts +0 -270
  28. package/dist/interfaces/chunks/contract-interactions.i.d.ts +0 -64
  29. package/dist/interfaces/chunks/contract-types.i.d.ts +0 -171
  30. package/dist/interfaces/chunks/lit-actions-results.i.d.ts +0 -165
  31. package/dist/interfaces/chunks/lit-actions.i.d.ts +0 -98
  32. package/dist/interfaces/chunks/loan-operations.i.d.ts +0 -331
  33. package/dist/interfaces/chunks/pkp-integration.i.d.ts +0 -87
  34. package/dist/interfaces/chunks/position-query.i.d.ts +0 -76
  35. package/dist/interfaces/chunks/requests.i.d.ts +0 -55
  36. package/dist/interfaces/chunks/ucd-minting.i.d.ts +0 -34
  37. package/dist/interfaces/chunks/utility.i.d.ts +0 -64
  38. package/dist/interfaces/index.d.ts +0 -17
  39. package/dist/modules/bitcoin/bitcoin-operations.module.d.ts +0 -254
  40. package/dist/modules/cache/cache-manager.module.d.ts +0 -259
  41. package/dist/modules/contract/contract-manager.module.d.ts +0 -152
  42. package/dist/modules/diamond-hands-sdk.d.ts +0 -969
  43. package/dist/modules/loan/loan-creator.module.d.ts +0 -132
  44. package/dist/modules/loan/loan-query.module.d.ts +0 -204
  45. package/dist/modules/mock/mock-token-manager.module.d.ts +0 -83
  46. package/dist/modules/pkp/pkp-manager.module.d.ts +0 -136
  47. package/dist/modules/withdrawal-address/withdrawal-address.module.d.ts +0 -78
  48. package/dist/protocol/protocol-pause.d.ts +0 -19
  49. package/dist/server.d.ts +0 -17
  50. package/dist/types/authorization-params.d.ts +0 -160
  51. package/dist/types/branded/domain-values.d.ts +0 -138
  52. package/dist/types/branded/ids.d.ts +0 -23
  53. package/dist/types/event-types.d.ts +0 -261
  54. package/dist/types/graph-dtos.d.ts +0 -228
  55. package/dist/types/loanStatus.d.ts +0 -10
  56. package/dist/types/protocol-event-types.d.ts +0 -99
  57. package/dist/types/result.d.ts +0 -120
  58. package/dist/utils/address-conversion.utils.d.ts +0 -51
  59. package/dist/utils/bitcoin-address-cache.utils.d.ts +0 -87
  60. package/dist/utils/bitcoin-provider.utils.d.ts +0 -84
  61. package/dist/utils/btc-withdrawal-message.d.ts +0 -60
  62. package/dist/utils/chunks/bitcoin-utils.d.ts +0 -85
  63. package/dist/utils/chunks/eip1559-broadcast.utils.d.ts +0 -33
  64. package/dist/utils/eip712-login.d.ts +0 -34
  65. package/dist/utils/error-handler.d.ts +0 -106
  66. package/dist/utils/ethers-interop.utils.d.ts +0 -146
  67. package/dist/utils/extend-authorization.utils.d.ts +0 -61
  68. package/dist/utils/lit-signature.utils.d.ts +0 -6
  69. package/dist/utils/logger.utils.d.ts +0 -142
  70. package/dist/utils/mint-authorization.utils.d.ts +0 -248
  71. package/dist/utils/position-delegate.utils.d.ts +0 -41
  72. package/dist/utils/quantum-timing.d.ts +0 -75
  73. package/dist/utils/server-session.d.ts +0 -50
  74. package/dist/utils/service-endpoint-policy.d.ts +0 -16
  75. package/dist/utils/signature-tempering.utils.d.ts +0 -34
  76. package/dist/utils/telegram-messaging.utils.d.ts +0 -188
@@ -1,228 +0,0 @@
1
- /**
2
- * Graph Data Transfer Objects (DTOs)
3
- * Strictly typed interfaces for GraphQL responses to replace any types
4
- */
5
- export type BigIntString = string;
6
- export type TimestampString = string;
7
- export type AddressString = string;
8
- export interface GraphPositionDTO {
9
- id: string;
10
- pkpId: string;
11
- borrower: string;
12
- createdAt: TimestampString;
13
- lastUpdated: TimestampString;
14
- vaultAddress: string;
15
- ucdMinted?: BigIntString;
16
- ucdPaid?: BigIntString;
17
- ucdDebt: BigIntString;
18
- selectedTerm: string;
19
- status: string;
20
- expiryAt: TimestampString;
21
- createdAtBlock?: string;
22
- lastUpdatedAt?: TimestampString;
23
- loanTerm?: {
24
- id: string;
25
- months: string;
26
- extensionFeeRate: string;
27
- extensionFeeUCD: string;
28
- totalExtensions: string;
29
- createdAt: string;
30
- };
31
- extensionFeesPaid?: string;
32
- totalExtensions?: string;
33
- payments?: Array<{
34
- id: string;
35
- amount: number;
36
- blockNumber: number;
37
- newCollateralRatio: number;
38
- newDebt: number;
39
- payer: {
40
- id: string;
41
- };
42
- createdAt: number;
43
- transactionHash: string;
44
- type: string;
45
- }>;
46
- totalPaid?: string;
47
- liquidation?: {
48
- id: string;
49
- liquidatedAt: string;
50
- liquidatedBy: string;
51
- reason: string;
52
- collateralRecovered: string;
53
- debtRecovered: string;
54
- liquidationFee: string;
55
- blockNumber: number;
56
- collateralSeized: string;
57
- commitHash: string;
58
- commitTimestamp: string;
59
- liquidatedAmount: string;
60
- liquidator: string;
61
- revealDelay: string;
62
- timestamp: string;
63
- transactionHash: string;
64
- };
65
- }
66
- export interface GraphBorrowerDTO {
67
- id: string;
68
- createdAt: TimestampString;
69
- }
70
- export interface GraphPositionWithBorrowerDTO extends Omit<GraphPositionDTO, 'borrower'> {
71
- borrower: GraphBorrowerDTO;
72
- }
73
- export interface GraphUserDataDTO {
74
- id: string;
75
- positions: GraphPositionDTO[];
76
- totalBorrowed: BigIntString;
77
- totalRepaid: BigIntString;
78
- activePositions: string;
79
- firstInteractionTimestamp: TimestampString;
80
- lastInteractionTimestamp: TimestampString;
81
- }
82
- export interface GraphLoanTermDTO {
83
- id: string;
84
- months: string;
85
- mintFeeBps?: string;
86
- extensionFeeBps?: string;
87
- isValid?: boolean;
88
- createdAt?: TimestampString;
89
- createdAtBlock?: string;
90
- }
91
- export interface GraphPSMConfigurationDTO {
92
- id: string;
93
- version: string;
94
- redeemEnabled: boolean;
95
- totalSwapVolume: BigIntString;
96
- totalRedeemVolume: BigIntString;
97
- supportedStablecoinsCount: string;
98
- lastUpdated: TimestampString;
99
- }
100
- export interface GraphSupportedStablecoinDTO {
101
- id: string;
102
- address: AddressString;
103
- isSupported: boolean;
104
- exchangeRate: BigIntString;
105
- entryFee: BigIntString;
106
- exitFee: BigIntString;
107
- reserves: BigIntString;
108
- totalSupply: BigIntString;
109
- lastUpdated: TimestampString;
110
- }
111
- export interface GraphPSMDailyMetricsDTO {
112
- id: string;
113
- date: string;
114
- totalSwapVolume: BigIntString;
115
- totalRedeemVolume: BigIntString;
116
- averageExchangeRate: BigIntString;
117
- uniqueUsers: string;
118
- transactionCount: string;
119
- }
120
- export interface GraphTokenDTO {
121
- id: string;
122
- address: AddressString;
123
- name: string;
124
- symbol: string;
125
- decimals: string;
126
- totalSupply: BigIntString;
127
- createdAtTimestamp: TimestampString;
128
- createdAtBlock: string;
129
- }
130
- export interface GraphAccountDTO {
131
- id: string;
132
- address: AddressString;
133
- balance: BigIntString;
134
- token: string;
135
- createdAtTimestamp: TimestampString;
136
- createdAtBlock: string;
137
- }
138
- export interface GraphMetaDTO {
139
- block: {
140
- number: string;
141
- hash: string;
142
- timestamp: string;
143
- };
144
- deployment: {
145
- network: string;
146
- chainId: string;
147
- subgraphName: string;
148
- version: string;
149
- };
150
- }
151
- export interface GraphPaginationDTO {
152
- first: number;
153
- skip: number;
154
- orderBy?: string;
155
- orderDirection?: 'asc' | 'desc';
156
- }
157
- export interface GraphPaginatedResponseDTO<T> {
158
- data: T[];
159
- total: number;
160
- page: number;
161
- hasMore: boolean;
162
- }
163
- export interface GraphPositionsResponseDTO {
164
- positions: GraphPositionWithBorrowerDTO[];
165
- _meta: GraphMetaDTO;
166
- }
167
- export interface GraphUserPositionsResponseDTO {
168
- positions: GraphPositionDTO[];
169
- total: number;
170
- }
171
- export interface GraphPositionsByStatusResponseDTO {
172
- positions: GraphPositionDTO[];
173
- total: number;
174
- }
175
- export interface GraphPSMDailyMetricsResponseDTO {
176
- psmDailyMetrics: GraphPSMDailyMetricsDTO[];
177
- }
178
- export interface GraphTokensResponseDTO {
179
- tokens: GraphTokenDTO[];
180
- }
181
- export interface GraphTokenResponseDTO {
182
- token: GraphTokenDTO;
183
- }
184
- export interface GraphAccountResponseDTO {
185
- account: GraphAccountDTO;
186
- }
187
- export interface GraphAccountsResponseDTO {
188
- accounts: GraphAccountDTO[];
189
- }
190
- export interface GraphPositionFilterDTO {
191
- borrower?: string;
192
- status?: string;
193
- pkpId?: string;
194
- createdAt_gte?: TimestampString;
195
- createdAt_lte?: TimestampString;
196
- }
197
- export interface GraphAccountFilterDTO {
198
- token?: string;
199
- minBalance?: BigIntString;
200
- address?: AddressString;
201
- }
202
- export interface GraphHealthCheckDTO {
203
- _meta: GraphMetaDTO;
204
- positionsCount: number;
205
- lastIndexedBlock: string;
206
- isHealthy: boolean;
207
- }
208
- export interface GraphErrorDTO {
209
- message: string;
210
- locations?: Array<{
211
- line: number;
212
- column: number;
213
- }>;
214
- path?: string[];
215
- extensions?: {
216
- code: string;
217
- exception?: {
218
- stacktrace: string[];
219
- };
220
- };
221
- }
222
- export interface GraphResponseDTO<T> {
223
- data?: T;
224
- errors?: GraphErrorDTO[];
225
- extensions?: {
226
- [key: string]: any;
227
- };
228
- }
@@ -1,10 +0,0 @@
1
- export declare enum LoanStatus {
2
- PENDING_DEPOSIT = 0,
3
- PENDING_MINT = 1,
4
- ACTIVE = 2,
5
- EXPIRED = 3,
6
- LIQUIDATABLE = 4,
7
- LIQUIDATED = 5,
8
- REPAID = 6,
9
- CLOSED = 7
10
- }
@@ -1,99 +0,0 @@
1
- /**
2
- * Protocol-wide event types for getAllEvents.
3
- * Position-scoped events are also available via getLoanEvents.
4
- */
5
- export type ProtocolEvent = {
6
- kind: 'position';
7
- subkind: 'created' | 'status' | 'renewed' | 'closed';
8
- positionId: string;
9
- timestamp: string;
10
- blockNumber: string;
11
- transactionHash: string;
12
- [k: string]: unknown;
13
- } | {
14
- kind: 'payment';
15
- positionId: string;
16
- timestamp: string;
17
- blockNumber: string;
18
- transactionHash: string;
19
- [k: string]: unknown;
20
- } | {
21
- kind: 'liquidation';
22
- positionId: string;
23
- timestamp: string;
24
- blockNumber: string;
25
- transactionHash: string;
26
- [k: string]: unknown;
27
- } | {
28
- kind: 'collateral';
29
- positionId: string;
30
- timestamp: string;
31
- blockNumber: string;
32
- transactionHash: string;
33
- [k: string]: unknown;
34
- } | {
35
- kind: 'mint';
36
- positionId: string;
37
- timestamp: string;
38
- blockNumber: string;
39
- transactionHash: string;
40
- [k: string]: unknown;
41
- } | {
42
- kind: 'withdrawal';
43
- positionId: string;
44
- timestamp: string;
45
- blockNumber: string;
46
- transactionHash: string;
47
- [k: string]: unknown;
48
- } | {
49
- kind: 'psm';
50
- subkind: 'swap' | 'redeem';
51
- timestamp: string;
52
- blockNumber: string;
53
- transactionHash: string;
54
- [k: string]: unknown;
55
- } | {
56
- kind: 'admin';
57
- subkind: 'circuitBreaker' | 'termFee' | 'loanParams' | 'maxLoanValue' | 'btcBounds' | 'mintLimit';
58
- timestamp: string;
59
- blockNumber: string;
60
- transactionHash: string;
61
- [k: string]: unknown;
62
- } | {
63
- kind: 'mintingFee';
64
- positionId: string;
65
- feeAmount: string;
66
- mintAmount: string;
67
- timestamp: string;
68
- blockNumber: string;
69
- transactionHash: string;
70
- [k: string]: unknown;
71
- } | {
72
- kind: 'renewalFee';
73
- positionId: string;
74
- feeAmount: string;
75
- extensionTerm: string;
76
- timestamp: string;
77
- blockNumber: string;
78
- transactionHash: string;
79
- [k: string]: unknown;
80
- };
81
- export interface ProtocolEventsFilter {
82
- /** Narrow all position-linked events to a single position */
83
- positionId?: string;
84
- /** Include only these event kinds (omit to include all) */
85
- kinds?: ProtocolEvent['kind'][];
86
- fromTimestamp?: string;
87
- toTimestamp?: string;
88
- fromBlock?: string;
89
- toBlock?: string;
90
- /** Per-entity query limit (default 1000) */
91
- limit?: number;
92
- orderDirection?: 'asc' | 'desc';
93
- }
94
- export interface ProtocolEventsResult {
95
- events: ProtocolEvent[];
96
- totalEvents: number;
97
- /** Count of events per kind for UI filter badges */
98
- byKind: Record<string, number>;
99
- }
@@ -1,120 +0,0 @@
1
- /**
2
- * Result type for standardized error handling across the SDK
3
- *
4
- * This is a discriminated union that provides type-safe error handling
5
- * without throwing exceptions. Inspired by Rust's Result<T, E> type.
6
- *
7
- * @example
8
- * ```typescript
9
- * async function createLoan(request: CreateLoanRequest): Promise<Result<LoanData, SDKError>> {
10
- * try {
11
- * const loan = await performCreation(request);
12
- * return success(loan);
13
- * } catch (error) {
14
- * return failure(SDKError.from(error));
15
- * }
16
- * }
17
- *
18
- * // Usage
19
- * const result = await createLoan(request);
20
- * if (result.success) {
21
- * console.log('Loan created:', result.value);
22
- * } else {
23
- * console.error('Failed:', result.error);
24
- * }
25
- * ```
26
- */
27
- /**
28
- * Success variant of Result<T, E>
29
- */
30
- export interface Success<T> {
31
- success: true;
32
- value: T;
33
- }
34
- /**
35
- * Failure variant of Result<T, E>
36
- */
37
- export interface Failure<E> {
38
- success: false;
39
- error: E;
40
- }
41
- /**
42
- * Result type - either Success<T> or Failure<E>
43
- */
44
- export type Result<T, E = Error> = Success<T> | Failure<E>;
45
- /**
46
- * Creates a successful Result
47
- */
48
- export declare function success<T>(value: T): Success<T>;
49
- /**
50
- * Creates a failed Result
51
- */
52
- export declare function failure<E>(error: E): Failure<E>;
53
- /**
54
- * Type guard to check if Result is successful
55
- */
56
- export declare function isSuccess<T, E>(result: Result<T, E>): result is Success<T>;
57
- /**
58
- * Type guard to check if Result is a failure
59
- */
60
- export declare function isFailure<T, E>(result: Result<T, E>): result is Failure<E>;
61
- /**
62
- * Unwraps a Result, returning the value or throwing the error
63
- */
64
- export declare function unwrap<T, E extends Error>(result: Result<T, E>): T;
65
- /**
66
- * Unwraps a Result, returning the value or a default
67
- */
68
- export declare function unwrapOr<T, E>(result: Result<T, E>, defaultValue: T): T;
69
- /**
70
- * Maps a Result<T, E> to Result<U, E> by applying a function to the success value
71
- */
72
- export declare function map<T, U, E>(result: Result<T, E>, fn: (value: T) => U): Result<U, E>;
73
- /**
74
- * Maps a Result<T, E> to Result<T, F> by applying a function to the error value
75
- */
76
- export declare function mapError<T, E, F>(result: Result<T, E>, fn: (error: E) => F): Result<T, F>;
77
- /**
78
- * Chains Result-returning operations together (flatMap)
79
- */
80
- export declare function andThen<T, U, E>(result: Result<T, E>, fn: (value: T) => Result<U, E>): Result<U, E>;
81
- /**
82
- * Returns the first successful Result, or the last error if all fail
83
- */
84
- export declare function firstSuccess<T, E>(results: Result<T, E>[]): Result<T, E>;
85
- /**
86
- * Collects all successful Results into an array
87
- */
88
- export declare function collectSuccesses<T, E>(results: Result<T, E>[]): T[];
89
- /**
90
- * Collects all failures into an array
91
- */
92
- export declare function collectFailures<T, E>(results: Result<T, E>[]): E[];
93
- /**
94
- * Combines multiple Results into a single Result containing an array
95
- * If any Result fails, returns the first failure
96
- */
97
- export declare function combine<T, E>(results: Result<T, E>[]): Result<T[], E>;
98
- /**
99
- * Wraps an async function that may throw into one that returns a Result
100
- */
101
- export declare function tryCatch<T, E = Error>(fn: () => T, errorHandler?: (error: unknown) => E): Result<T, E>;
102
- /**
103
- * Async version of tryCatch
104
- */
105
- export declare function tryCatchAsync<T, E = Error>(fn: () => Promise<T>, errorHandler?: (error: unknown) => E): Promise<Result<T, E>>;
106
- /**
107
- * Converts a Result to a Promise that rejects on failure
108
- */
109
- export declare function toPromise<T, E extends Error>(result: Result<T, E>): Promise<T>;
110
- /**
111
- * Converts a Promise to a Result (will never reject)
112
- */
113
- export declare function fromPromise<T, E = Error>(promise: Promise<T>, errorHandler?: (error: unknown) => E): Promise<Result<T, E>>;
114
- /**
115
- * Utility to match on a Result and handle both cases
116
- */
117
- export declare function match<T, E, U>(result: Result<T, E>, handlers: {
118
- success: (value: T) => U;
119
- failure: (error: E) => U;
120
- }): U;
@@ -1,51 +0,0 @@
1
- /**
2
- * Address Conversion Utilities
3
- * Provides safe address conversion and validation with clear error messages
4
- */
5
- /**
6
- * Safely convert a string to bytes32 with clear error handling
7
- * @param value String value to convert
8
- * @param fieldName Name of the field for error messages
9
- * @returns bytes32 string
10
- * @throws Clear error message if conversion fails
11
- */
12
- export declare function safeHexZeroPad(value: string, fieldName?: string): string;
13
- /**
14
- * Safely get Bitcoin addresses from PKP with retry and clear error handling
15
- * @param pkpId PKP ID to derive addresses from
16
- * @param maxRetries Maximum number of retries (default: 3)
17
- * @returns Bitcoin addresses for all networks
18
- * @throws Clear error message if derivation fails
19
- */
20
- export declare function safeGetBitcoinAddressesFromPkp(pkpId: string, maxRetries?: number): Promise<{
21
- mainnet: string;
22
- testnet: string;
23
- regtest: string;
24
- }>;
25
- /**
26
- * Safely validate and format a Bitcoin address
27
- * @param address Bitcoin address to validate
28
- * @param network Network type for validation
29
- * @returns Validated address
30
- * @throws Clear error message if validation fails
31
- */
32
- export declare function safeValidateBitcoinAddress(address: string, network?: 'mainnet' | 'testnet' | 'regtest'): string;
33
- /**
34
- * Canonicalize a Bitcoin address so that the SAME string is used on both the
35
- * approve path (registry.addAddress) and the withdraw path. The on-chain
36
- * allowlist is keyed by keccak256(bytes(address)), so the two strings MUST
37
- * byte-match. Bech32 (bc1/tb1/bcrt1) is lower-case canonical, so we lower-case
38
- * it; Base58 (1.../3.../m.../n.../2...) is case-sensitive and is returned
39
- * unchanged.
40
- *
41
- * @param address Bitcoin address to canonicalize
42
- * @returns The canonical form to store/compare
43
- */
44
- export declare function normalizeBitcoinAddress(address: string): string;
45
- /**
46
- * Safely parse and validate a position ID
47
- * @param positionId Position ID to validate
48
- * @returns Validated position ID
49
- * @throws Clear error message if validation fails
50
- */
51
- export declare function safeValidatePositionId(positionId: string): string;
@@ -1,87 +0,0 @@
1
- /**
2
- * Bitcoin Address Derivation Cache Utility
3
- * Implements LRU (Least Recently Used) caching for Bitcoin address derivation from PKP
4
- * Avoids repeated SHA256+RIPEMD160 operations for the same PKP ID
5
- */
6
- import type { BitcoinAddresses } from '../interfaces';
7
- /**
8
- * Cache statistics
9
- */
10
- export interface AddressCacheStats {
11
- size: number;
12
- hits: number;
13
- misses: number;
14
- evictions: number;
15
- hitRate: number;
16
- }
17
- /**
18
- * Address cache configuration
19
- */
20
- export interface AddressCacheConfig {
21
- maxSize?: number;
22
- ttlMs?: number;
23
- debug?: boolean;
24
- }
25
- /**
26
- * LRU Cache for Bitcoin address derivation
27
- *
28
- * Features:
29
- * - TTL-based expiration
30
- * - LRU eviction when max size reached
31
- * - Hit/miss statistics tracking
32
- * - Memory-efficient (stores only PKP ID and derived addresses)
33
- */
34
- export declare class BitcoinAddressCache {
35
- private cache;
36
- private maxSize;
37
- private ttlMs;
38
- private debug;
39
- private stats;
40
- constructor(config?: AddressCacheConfig);
41
- /**
42
- * Get addresses from cache
43
- * Returns null if not found or expired
44
- */
45
- get(pkpId: string): BitcoinAddresses | null;
46
- /**
47
- * Set addresses in cache
48
- * Evicts LRU entry if cache is full
49
- */
50
- set(pkpId: string, value: BitcoinAddresses): void;
51
- /**
52
- * Check if entry is expired
53
- */
54
- private isExpired;
55
- /**
56
- * Evict least recently used entry
57
- */
58
- private evictLRU;
59
- /**
60
- * Clear all entries
61
- */
62
- clear(): void;
63
- /**
64
- * Get cache statistics
65
- */
66
- getStats(): AddressCacheStats;
67
- /**
68
- * Get cache size
69
- */
70
- size(): number;
71
- /**
72
- * Check if cache has entry
73
- */
74
- has(pkpId: string): boolean;
75
- /**
76
- * Delete specific entry
77
- */
78
- delete(pkpId: string): boolean;
79
- /**
80
- * Get all cached PKP IDs (for debugging)
81
- */
82
- getKeys(): string[];
83
- /**
84
- * Clean expired entries
85
- */
86
- cleanExpired(): number;
87
- }
@@ -1,84 +0,0 @@
1
- /**
2
- * Bitcoin Provider Utilities
3
- * Handles multi-provider consensus for Bitcoin blockchain queries
4
- */
5
- import type { BitcoinProviderConfig } from '../interfaces/chunks/config.i';
6
- import type { BitcoinBalanceResult } from '../interfaces/chunks/position-query.i';
7
- /**
8
- * Bitcoin Provider with consensus support
9
- */
10
- export declare class BitcoinProvider {
11
- private providers;
12
- private consensusMode;
13
- private debug;
14
- constructor(configs: BitcoinProviderConfig[], consensusMode?: 'single' | 'majority', debug?: boolean);
15
- /**
16
- * Get UTXOs for a Bitcoin address with consensus
17
- */
18
- getUnspentsFor(address: string): Promise<BitcoinBalanceResult>;
19
- /**
20
- * Get UTXOs from a single provider
21
- */
22
- private getUnspentsSingle;
23
- /**
24
- * Check if a provider error is retryable
25
- */
26
- private isRetryableProviderError;
27
- /**
28
- * Get UTXOs with 2-of-3 consensus
29
- */
30
- private getUnspentsWithConsensus;
31
- /**
32
- * Find consensus among multiple provider results
33
- */
34
- private findConsensus;
35
- /**
36
- * Create a signature for a UTXO set (for comparison)
37
- */
38
- private getUTXOSetSignature;
39
- private fetchUtxosFromProvider;
40
- /**
41
- * Get balance for an address (sum of UTXOs)
42
- */
43
- getBalance(address: string): Promise<bigint>;
44
- /**
45
- * Check if an address has received at least a specific amount
46
- */
47
- hasReceivedAmount(address: string, expectedAmount: bigint): Promise<boolean>;
48
- /**
49
- * Fetch a Bitcoin transaction by txid.
50
- *
51
- * Audit CRIT-2: used to verify that a Phase-2 BTC withdrawal the server
52
- * claimed broadcast actually exists and matches the user's authorization.
53
- * Returns `null` if no provider has the tx yet — the caller may retry to
54
- * allow for propagation/indexing delay.
55
- *
56
- * Esplora response shape: `{ txid, vin: [{txid, vout, ...}], vout: [{value, scriptpubkey_address, ...}], status: {confirmed, ...} }`
57
- */
58
- getTransaction(txid: string): Promise<BitcoinTransactionInfo | null>;
59
- /**
60
- * Try each candidate path on the provider. Returns `null` on 404 (tx not
61
- * yet visible) but throws on other errors so the outer loop can move to
62
- * the next provider.
63
- */
64
- private fetchTxFromProvider;
65
- }
66
- /**
67
- * Normalized Bitcoin transaction information returned by `getTransaction`.
68
- * Only the fields used by post-broadcast verification are populated; we
69
- * deliberately do NOT echo full witness / scriptpubkey data to keep the
70
- * surface small.
71
- */
72
- export interface BitcoinTransactionInfo {
73
- txid: string;
74
- vin: Array<{
75
- txid: string;
76
- vout: number;
77
- }>;
78
- vout: Array<{
79
- value: number;
80
- address?: string;
81
- }>;
82
- /** True if the tx is in a block, false if still in mempool, undefined unknown. */
83
- confirmed?: boolean;
84
- }