@gvnrdao/dh-sdk 0.0.288 → 0.0.289
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/browser/dist/833.browser.js +1 -1
- package/browser/dist/browser.js +1 -1
- package/browser/dist/browser.js.LICENSE.txt +5 -10
- package/dist/constants/chunks/contract-abis.d.ts +20 -0
- package/dist/constants/chunks/deployment-addresses.d.ts +79 -0
- package/dist/constants/chunks/encrypted-provider-params.d.ts +21 -0
- package/dist/constants/chunks/environment.browser.d.ts +44 -0
- package/dist/constants/chunks/environment.d.ts +57 -0
- package/dist/constants/chunks/network-configs.d.ts +72 -0
- package/dist/constants/chunks/sdk-config.d.ts +33 -0
- package/dist/constants/chunks/sdk-limits.d.ts +66 -0
- package/dist/constants/index.d.ts +15 -0
- package/dist/contracts/typechain-contracts/common.d.ts +50 -0
- package/dist/contracts/typechain-contracts/factories/src/psm/SimplePSMV2__factory.d.ts +1996 -0
- package/dist/contracts/typechain-contracts/src/psm/SimplePSMV2.d.ts +1198 -0
- package/dist/deployments.js +21 -45
- package/dist/deployments.mjs +21 -45
- package/dist/graphs/client.d.ts +22 -0
- package/dist/graphs/diamond-hands.d.ts +259 -0
- package/dist/index.d.ts +56 -0
- package/dist/index.js +1123 -628
- package/dist/index.mjs +1123 -628
- package/dist/interfaces/chunks/btc.i.d.ts +36 -0
- package/dist/interfaces/chunks/config.i.d.ts +270 -0
- package/dist/interfaces/chunks/contract-interactions.i.d.ts +64 -0
- package/dist/interfaces/chunks/contract-types.i.d.ts +171 -0
- package/dist/interfaces/chunks/lit-actions-results.i.d.ts +165 -0
- package/dist/interfaces/chunks/lit-actions.i.d.ts +98 -0
- package/dist/interfaces/chunks/loan-operations.i.d.ts +331 -0
- package/dist/interfaces/chunks/pkp-integration.i.d.ts +87 -0
- package/dist/interfaces/chunks/position-query.i.d.ts +76 -0
- package/dist/interfaces/chunks/requests.i.d.ts +55 -0
- package/dist/interfaces/chunks/ucd-minting.i.d.ts +34 -0
- package/dist/interfaces/chunks/utility.i.d.ts +64 -0
- package/dist/interfaces/index.d.ts +17 -0
- package/dist/modules/bitcoin/bitcoin-operations.module.d.ts +254 -0
- package/dist/modules/cache/cache-manager.module.d.ts +259 -0
- package/dist/modules/contract/contract-manager.module.d.ts +152 -0
- package/dist/modules/diamond-hands-sdk.d.ts +969 -0
- package/dist/modules/loan/loan-creator.module.d.ts +132 -0
- package/dist/modules/loan/loan-query.module.d.ts +204 -0
- package/dist/modules/mock/mock-token-manager.module.d.ts +83 -0
- package/dist/modules/pkp/pkp-manager.module.d.ts +136 -0
- package/dist/modules/withdrawal-address/withdrawal-address.module.d.ts +78 -0
- package/dist/protocol/protocol-pause.d.ts +19 -0
- package/dist/server.d.ts +17 -0
- package/dist/types/authorization-params.d.ts +160 -0
- package/dist/types/branded/domain-values.d.ts +138 -0
- package/dist/types/branded/ids.d.ts +23 -0
- package/dist/types/event-types.d.ts +261 -0
- package/dist/types/graph-dtos.d.ts +228 -0
- package/dist/types/loanStatus.d.ts +10 -0
- package/dist/types/protocol-event-types.d.ts +99 -0
- package/dist/types/result.d.ts +120 -0
- package/dist/utils/address-conversion.utils.d.ts +51 -0
- package/dist/utils/bitcoin-address-cache.utils.d.ts +87 -0
- package/dist/utils/bitcoin-provider.utils.d.ts +84 -0
- package/dist/utils/btc-withdrawal-message.d.ts +60 -0
- package/dist/utils/chunks/bitcoin-utils.d.ts +85 -0
- package/dist/utils/chunks/eip1559-broadcast.utils.d.ts +33 -0
- package/dist/utils/eip712-login.d.ts +34 -0
- package/dist/utils/error-handler.d.ts +106 -0
- package/dist/utils/ethers-interop.utils.d.ts +146 -0
- package/dist/utils/extend-authorization.utils.d.ts +61 -0
- package/dist/utils/lit-signature.utils.d.ts +6 -0
- package/dist/utils/logger.utils.d.ts +142 -0
- package/dist/utils/mint-authorization.utils.d.ts +248 -0
- package/dist/utils/position-delegate.utils.d.ts +41 -0
- package/dist/utils/quantum-timing.d.ts +75 -0
- package/dist/utils/server-session.d.ts +50 -0
- package/dist/utils/service-endpoint-policy.d.ts +16 -0
- package/dist/utils/signature-tempering.utils.d.ts +34 -0
- package/dist/utils/telegram-messaging.utils.d.ts +188 -0
- package/package.json +1 -1
- package/browser/dist/397.browser.js +0 -2
- package/browser/dist/397.browser.js.LICENSE.txt +0 -1
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Position Query Interfaces
|
|
3
|
+
*/
|
|
4
|
+
import { LoanStatus } from "../../types/loanStatus";
|
|
5
|
+
/**
|
|
6
|
+
* Position data structure (from contract)
|
|
7
|
+
*/
|
|
8
|
+
export interface Position {
|
|
9
|
+
positionId: string;
|
|
10
|
+
pkpId: string;
|
|
11
|
+
borrower: string;
|
|
12
|
+
vaultAddress: string;
|
|
13
|
+
vaultAddressRegtest?: string;
|
|
14
|
+
ucdDebt: bigint;
|
|
15
|
+
createdAt: number;
|
|
16
|
+
lastUpdated: number;
|
|
17
|
+
expiryAt: number;
|
|
18
|
+
status: LoanStatus;
|
|
19
|
+
collateralRatio?: number;
|
|
20
|
+
requestedCollateralRatio?: number;
|
|
21
|
+
selectedTerm: number;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Bitcoin UTXO (Unspent Transaction Output)
|
|
25
|
+
*/
|
|
26
|
+
export interface BitcoinUTXO {
|
|
27
|
+
txId: string;
|
|
28
|
+
vout: number;
|
|
29
|
+
value: number;
|
|
30
|
+
confirmations: number;
|
|
31
|
+
scriptPubKey?: string;
|
|
32
|
+
address?: string;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Position with Bitcoin status
|
|
36
|
+
*/
|
|
37
|
+
export interface PositionWithBTCStatus extends Position {
|
|
38
|
+
btcStatus: {
|
|
39
|
+
actualAmount: bigint;
|
|
40
|
+
confirmations: number;
|
|
41
|
+
utxos: BitcoinUTXO[];
|
|
42
|
+
lastCheckedAt: number;
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Position query options
|
|
47
|
+
*/
|
|
48
|
+
export interface PositionQueryOptions {
|
|
49
|
+
borrower?: string;
|
|
50
|
+
status?: LoanStatus | LoanStatus[];
|
|
51
|
+
verifyBTC?: boolean;
|
|
52
|
+
offset?: number;
|
|
53
|
+
limit?: number;
|
|
54
|
+
sortBy?: 'createdAt' | 'lastUpdated' | 'ucdDebt';
|
|
55
|
+
sortDirection?: 'asc' | 'desc';
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Position query result
|
|
59
|
+
*/
|
|
60
|
+
export interface PositionQueryResult {
|
|
61
|
+
positions: Position[] | PositionWithBTCStatus[];
|
|
62
|
+
total: number;
|
|
63
|
+
hasMore: boolean;
|
|
64
|
+
executionTimeMs: number;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Bitcoin balance check result
|
|
68
|
+
*/
|
|
69
|
+
export interface BitcoinBalanceResult {
|
|
70
|
+
address: string;
|
|
71
|
+
balance: bigint;
|
|
72
|
+
utxos: BitcoinUTXO[];
|
|
73
|
+
confirmations: number;
|
|
74
|
+
provider: string;
|
|
75
|
+
timestamp: number;
|
|
76
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* General Request/Response Types and Interfaces
|
|
3
|
+
*/
|
|
4
|
+
import { AuthorizationParams } from '../../types/authorization-params';
|
|
5
|
+
/**
|
|
6
|
+
* Authorization request with type-safe parameters
|
|
7
|
+
*/
|
|
8
|
+
export interface AuthorizationRequest {
|
|
9
|
+
/** PKP token ID */
|
|
10
|
+
pkpId: string;
|
|
11
|
+
/** Action being authorized (derived from params.type) */
|
|
12
|
+
action: string;
|
|
13
|
+
/** Type-safe authorization parameters (discriminated union) */
|
|
14
|
+
params: AuthorizationParams;
|
|
15
|
+
/** Authorization signature */
|
|
16
|
+
signature: string;
|
|
17
|
+
/** Request timestamp */
|
|
18
|
+
timestamp: number;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Result of an authorization check
|
|
22
|
+
*/
|
|
23
|
+
export interface AuthorizationResult {
|
|
24
|
+
/** Whether the authorization was successful */
|
|
25
|
+
authorized: boolean;
|
|
26
|
+
/** PKP token ID that was checked */
|
|
27
|
+
pkpId: string;
|
|
28
|
+
/** Error message if authorization failed */
|
|
29
|
+
error?: string;
|
|
30
|
+
/** Additional details about the authorization (type-safe per action) */
|
|
31
|
+
details?: unknown;
|
|
32
|
+
}
|
|
33
|
+
export interface ValidationRequest {
|
|
34
|
+
data: any;
|
|
35
|
+
rules: string[];
|
|
36
|
+
context?: Record<string, any>;
|
|
37
|
+
}
|
|
38
|
+
export interface ConfirmationResult {
|
|
39
|
+
confirmed: boolean;
|
|
40
|
+
confirmations: number;
|
|
41
|
+
blockHeight?: number;
|
|
42
|
+
txHash?: string;
|
|
43
|
+
error?: string;
|
|
44
|
+
}
|
|
45
|
+
export interface BTCDepositRequest {
|
|
46
|
+
positionId: string;
|
|
47
|
+
}
|
|
48
|
+
export interface BTCDepositResult {
|
|
49
|
+
success: boolean;
|
|
50
|
+
positionId?: string;
|
|
51
|
+
vaultBalance?: string;
|
|
52
|
+
hasBalance?: boolean;
|
|
53
|
+
validationResponse?: any;
|
|
54
|
+
error?: string;
|
|
55
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UCD Minting Types and Interfaces
|
|
3
|
+
*/
|
|
4
|
+
export interface IUCDMinting {
|
|
5
|
+
mint(params: MintingParams): Promise<MintingResult>;
|
|
6
|
+
calculateRewards(amount: string): Promise<RewardDistribution>;
|
|
7
|
+
validateMinting(params: MintingParams): Promise<boolean>;
|
|
8
|
+
}
|
|
9
|
+
export interface MintingParams {
|
|
10
|
+
amount: string;
|
|
11
|
+
recipient: string;
|
|
12
|
+
collateralType: string;
|
|
13
|
+
collateralAmount: string;
|
|
14
|
+
oracleData?: any;
|
|
15
|
+
}
|
|
16
|
+
export interface MintingResult {
|
|
17
|
+
success: boolean;
|
|
18
|
+
txHash?: string;
|
|
19
|
+
mintedAmount?: string;
|
|
20
|
+
fees?: string;
|
|
21
|
+
rewards?: RewardDistribution;
|
|
22
|
+
error?: string;
|
|
23
|
+
}
|
|
24
|
+
export interface RewardDistribution {
|
|
25
|
+
totalRewards: string;
|
|
26
|
+
operatorReward: string;
|
|
27
|
+
protocolReward: string;
|
|
28
|
+
liquidityProviderReward: string;
|
|
29
|
+
distribution: {
|
|
30
|
+
operator: string;
|
|
31
|
+
protocol: string;
|
|
32
|
+
liquidityProvider: string;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility Type Interfaces
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Generic Result Interface
|
|
6
|
+
*/
|
|
7
|
+
export interface Result<T = any> {
|
|
8
|
+
success: boolean;
|
|
9
|
+
error?: string;
|
|
10
|
+
data?: T;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Pagination Interface
|
|
14
|
+
*/
|
|
15
|
+
export interface Pagination {
|
|
16
|
+
page: number;
|
|
17
|
+
limit: number;
|
|
18
|
+
total?: number;
|
|
19
|
+
hasNext?: boolean;
|
|
20
|
+
hasPrev?: boolean;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Paginated Result Interface
|
|
24
|
+
*/
|
|
25
|
+
export interface PaginatedResult<T = any> extends Result<T[]> {
|
|
26
|
+
pagination?: Pagination;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Audit Trail Interface
|
|
30
|
+
*/
|
|
31
|
+
export interface AuditTrail {
|
|
32
|
+
operation: string;
|
|
33
|
+
timestamp: number;
|
|
34
|
+
duration?: number;
|
|
35
|
+
success: boolean;
|
|
36
|
+
error?: string;
|
|
37
|
+
metadata?: Record<string, any>;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Debug Information Interface
|
|
41
|
+
*/
|
|
42
|
+
export interface DebugInfo {
|
|
43
|
+
logs: string[];
|
|
44
|
+
metrics?: {
|
|
45
|
+
startTime: number;
|
|
46
|
+
endTime: number;
|
|
47
|
+
duration: number;
|
|
48
|
+
};
|
|
49
|
+
networkCalls?: {
|
|
50
|
+
url: string;
|
|
51
|
+
method: string;
|
|
52
|
+
duration: number;
|
|
53
|
+
success: boolean;
|
|
54
|
+
}[];
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Retry Configuration Interface
|
|
58
|
+
*/
|
|
59
|
+
export interface RetryConfig {
|
|
60
|
+
maxAttempts: number;
|
|
61
|
+
delay: number;
|
|
62
|
+
backoffMultiplier?: number;
|
|
63
|
+
maxDelay?: number;
|
|
64
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Diamond Hands SDK Interfaces
|
|
3
|
+
* All TypeScript interfaces and types used in the SDK package
|
|
4
|
+
*
|
|
5
|
+
* Following the golden source pattern with organized chunks
|
|
6
|
+
*/
|
|
7
|
+
export * from "./chunks/config.i";
|
|
8
|
+
export * from "./chunks/contract-types.i";
|
|
9
|
+
export * from "./chunks/loan-operations.i";
|
|
10
|
+
export * from "./chunks/pkp-integration.i";
|
|
11
|
+
export * from "./chunks/contract-interactions.i";
|
|
12
|
+
export * from "./chunks/utility.i";
|
|
13
|
+
export * from "./chunks/btc.i";
|
|
14
|
+
export * from "./chunks/lit-actions.i";
|
|
15
|
+
export * from "./chunks/ucd-minting.i";
|
|
16
|
+
export * from "./chunks/requests.i";
|
|
17
|
+
export * from "./chunks/position-query.i";
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bitcoin Operations Module
|
|
3
|
+
*
|
|
4
|
+
* Responsible for:
|
|
5
|
+
* - Deriving Bitcoin addresses from PKP public keys
|
|
6
|
+
* - Querying Bitcoin balances (with multi-provider consensus)
|
|
7
|
+
* - Validating Bitcoin transactions
|
|
8
|
+
* - Caching Bitcoin data for performance
|
|
9
|
+
*
|
|
10
|
+
* Uses branded types (Satoshis) for type-safe Bitcoin amounts
|
|
11
|
+
*/
|
|
12
|
+
import { Result } from "../../types/result";
|
|
13
|
+
import { Satoshis } from "../../types/branded/domain-values";
|
|
14
|
+
import { SDKError } from "../../utils/error-handler";
|
|
15
|
+
import type { Cache } from "../cache/cache-manager.module";
|
|
16
|
+
import type { BitcoinAddresses } from "../../interfaces/chunks/loan-operations.i";
|
|
17
|
+
import type { BitcoinBalanceResult, BitcoinUTXO } from "../../interfaces/chunks/position-query.i";
|
|
18
|
+
import type { BitcoinProviderConfig, PriceProviderConfig } from "../../interfaces/chunks/config.i";
|
|
19
|
+
/**
|
|
20
|
+
* Bitcoin network type
|
|
21
|
+
*/
|
|
22
|
+
export type BitcoinNetwork = "mainnet" | "testnet" | "regtest";
|
|
23
|
+
/**
|
|
24
|
+
* Bitcoin Operations configuration
|
|
25
|
+
*/
|
|
26
|
+
export interface BitcoinOperationsConfig {
|
|
27
|
+
/** Bitcoin network to use */
|
|
28
|
+
network: BitcoinNetwork;
|
|
29
|
+
/** Bitcoin provider configurations (supports 1-3 for consensus) */
|
|
30
|
+
providers: BitcoinProviderConfig[];
|
|
31
|
+
/** Consensus mode: single or majority */
|
|
32
|
+
consensusMode?: "single" | "majority";
|
|
33
|
+
/** Cache for balance results (keyed by address) */
|
|
34
|
+
balanceCache?: Cache<BitcoinBalanceResult>;
|
|
35
|
+
/** Cache for address derivations (keyed by PKP public key) */
|
|
36
|
+
addressCache?: Cache<BitcoinAddresses>;
|
|
37
|
+
/** LitOps instance for price oracle queries (optional) */
|
|
38
|
+
litOps?: any;
|
|
39
|
+
/** Signer for LIT Protocol operations (required for getBTCPrice) */
|
|
40
|
+
signer?: any;
|
|
41
|
+
/** Optional PKP Ethereum address for signed price oracle (Lit jsParams pkpId) */
|
|
42
|
+
priceOraclePkpId?: string;
|
|
43
|
+
/** Price feed API credentials passed to the price-oracle Lit Action. Must be exactly
|
|
44
|
+
* 3 entries from the locked set: cryptocompare, coinmarketcap, coingecko. */
|
|
45
|
+
priceProviders?: PriceProviderConfig[];
|
|
46
|
+
/** Enable debug logging */
|
|
47
|
+
debug?: boolean;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Bitcoin balance with enhanced metadata
|
|
51
|
+
*/
|
|
52
|
+
export interface EnrichedBitcoinBalance {
|
|
53
|
+
/** Bitcoin address */
|
|
54
|
+
address: string;
|
|
55
|
+
/** Balance in satoshis (branded type) */
|
|
56
|
+
balance: Satoshis;
|
|
57
|
+
/** UTXOs for this address */
|
|
58
|
+
utxos: BitcoinUTXO[];
|
|
59
|
+
/** Minimum confirmations across UTXOs */
|
|
60
|
+
confirmations: number;
|
|
61
|
+
/** Provider name that returned this data */
|
|
62
|
+
provider: string;
|
|
63
|
+
/** Timestamp when fetched */
|
|
64
|
+
timestamp: number;
|
|
65
|
+
/** Whether this data came from cache */
|
|
66
|
+
cached: boolean;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Bitcoin price result from LIT Protocol price oracle
|
|
70
|
+
*/
|
|
71
|
+
export interface BTCPriceResult {
|
|
72
|
+
/** Price with 8 decimals (e.g., "10679200000000" for $106,792) */
|
|
73
|
+
priceE8: string;
|
|
74
|
+
/** Price in USD as a number */
|
|
75
|
+
price: number;
|
|
76
|
+
/** Unix timestamp when price was fetched */
|
|
77
|
+
timestamp: number;
|
|
78
|
+
/** Source: "fast" (single source), "consensus" (multiple sources), or "fast-fallback" */
|
|
79
|
+
source: string;
|
|
80
|
+
/** Optional PKP signature on the price data */
|
|
81
|
+
signature?: string;
|
|
82
|
+
/** Optional signer address */
|
|
83
|
+
signer?: string;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Bitcoin Operations Module
|
|
87
|
+
*
|
|
88
|
+
* Handles all Bitcoin-related operations with type safety and caching
|
|
89
|
+
*/
|
|
90
|
+
export declare class BitcoinOperations {
|
|
91
|
+
private readonly config;
|
|
92
|
+
private readonly provider;
|
|
93
|
+
private readonly litOps?;
|
|
94
|
+
constructor(config: BitcoinOperationsConfig);
|
|
95
|
+
/**
|
|
96
|
+
* Derive Bitcoin addresses from PKP public key
|
|
97
|
+
*
|
|
98
|
+
* Generates addresses for all networks (mainnet, testnet, regtest)
|
|
99
|
+
* and caches the result.
|
|
100
|
+
*
|
|
101
|
+
* @param publicKey - PKP public key (hex string)
|
|
102
|
+
* @returns Bitcoin addresses for all networks
|
|
103
|
+
*/
|
|
104
|
+
deriveAddresses(publicKey: string): Promise<Result<BitcoinAddresses, SDKError>>;
|
|
105
|
+
/**
|
|
106
|
+
* Get Bitcoin address for current network
|
|
107
|
+
*
|
|
108
|
+
* Convenience method that returns only the address for the configured network.
|
|
109
|
+
*
|
|
110
|
+
* @param publicKey - PKP public key
|
|
111
|
+
* @returns Bitcoin address for current network
|
|
112
|
+
*/
|
|
113
|
+
getAddressForNetwork(publicKey: string): Promise<Result<string, SDKError>>;
|
|
114
|
+
/**
|
|
115
|
+
* Get Bitcoin balance for an address
|
|
116
|
+
*
|
|
117
|
+
* Queries balance using configured providers with consensus if enabled.
|
|
118
|
+
* Results are cached for performance.
|
|
119
|
+
*
|
|
120
|
+
* @param address - Bitcoin address
|
|
121
|
+
* @param skipCache - Skip cache and force fresh query
|
|
122
|
+
* @returns Enriched balance information
|
|
123
|
+
*/
|
|
124
|
+
getBalance(address: string, skipCache?: boolean): Promise<Result<EnrichedBitcoinBalance, SDKError>>;
|
|
125
|
+
/**
|
|
126
|
+
* Get balance with consensus across multiple providers
|
|
127
|
+
*
|
|
128
|
+
* Only available if multiple providers are configured.
|
|
129
|
+
*
|
|
130
|
+
* @param address - Bitcoin address
|
|
131
|
+
* @returns Consensus balance result
|
|
132
|
+
*/
|
|
133
|
+
getBalanceWithConsensus(address: string): Promise<Result<EnrichedBitcoinBalance, SDKError>>;
|
|
134
|
+
/**
|
|
135
|
+
* Get balances for multiple addresses
|
|
136
|
+
*
|
|
137
|
+
* Efficiently queries balances for multiple addresses in parallel.
|
|
138
|
+
*
|
|
139
|
+
* @param addresses - Array of Bitcoin addresses
|
|
140
|
+
* @returns Array of balance results
|
|
141
|
+
*/
|
|
142
|
+
getBalances(addresses: string[]): Promise<Result<EnrichedBitcoinBalance[], SDKError>>;
|
|
143
|
+
/**
|
|
144
|
+
* Get balance for a PKP public key
|
|
145
|
+
*
|
|
146
|
+
* Convenience method that derives address and queries balance.
|
|
147
|
+
*
|
|
148
|
+
* @param publicKey - PKP public key
|
|
149
|
+
* @returns Balance for the PKP's Bitcoin address
|
|
150
|
+
*/
|
|
151
|
+
getBalanceForPKP(publicKey: string): Promise<Result<EnrichedBitcoinBalance, SDKError>>;
|
|
152
|
+
/**
|
|
153
|
+
* Validate a Bitcoin address
|
|
154
|
+
*
|
|
155
|
+
* Checks if an address has a valid format.
|
|
156
|
+
*
|
|
157
|
+
* @param address - Bitcoin address
|
|
158
|
+
* @returns Whether address is valid
|
|
159
|
+
*/
|
|
160
|
+
validateAddress(address: string): boolean;
|
|
161
|
+
/**
|
|
162
|
+
* Clear balance cache for an address
|
|
163
|
+
*
|
|
164
|
+
* Forces next balance query to fetch fresh data.
|
|
165
|
+
*
|
|
166
|
+
* @param address - Bitcoin address
|
|
167
|
+
*/
|
|
168
|
+
clearBalanceCache(address: string): void;
|
|
169
|
+
/**
|
|
170
|
+
* Clear all balance cache
|
|
171
|
+
*/
|
|
172
|
+
clearAllBalanceCache(): void;
|
|
173
|
+
/**
|
|
174
|
+
* Clear address cache for a public key
|
|
175
|
+
*
|
|
176
|
+
* Forces next address derivation to compute fresh.
|
|
177
|
+
*
|
|
178
|
+
* @param publicKey - PKP public key
|
|
179
|
+
*/
|
|
180
|
+
clearAddressCache(publicKey: string): void;
|
|
181
|
+
/**
|
|
182
|
+
* Clear all address cache
|
|
183
|
+
*/
|
|
184
|
+
clearAllAddressCache(): void;
|
|
185
|
+
/**
|
|
186
|
+
* Get balance cache statistics
|
|
187
|
+
*/
|
|
188
|
+
getBalanceCacheStats(): import("../cache/cache-manager.module").CacheStats | null;
|
|
189
|
+
/**
|
|
190
|
+
* Get address cache statistics
|
|
191
|
+
*/
|
|
192
|
+
getAddressCacheStats(): import("../cache/cache-manager.module").CacheStats | null;
|
|
193
|
+
/**
|
|
194
|
+
* Get current network configuration
|
|
195
|
+
*/
|
|
196
|
+
getNetwork(): BitcoinNetwork;
|
|
197
|
+
/**
|
|
198
|
+
* Check if consensus mode is enabled
|
|
199
|
+
*/
|
|
200
|
+
isConsensusEnabled(): boolean;
|
|
201
|
+
/**
|
|
202
|
+
* Audit CRIT-2: verify a Phase-2 BTC withdrawal that the lit-ops-server
|
|
203
|
+
* claimed broadcast actually exists on chain and matches the user's
|
|
204
|
+
* authorization.
|
|
205
|
+
*
|
|
206
|
+
* Behavior:
|
|
207
|
+
* - If we successfully fetch the tx AND it disagrees with what the user
|
|
208
|
+
* authorized → throws (hard fail; server lied).
|
|
209
|
+
* - If we fetch the tx and it matches → returns `{ verified: true }`.
|
|
210
|
+
* - If no provider has the tx after `maxAttempts` retries → returns
|
|
211
|
+
* `{ verified: false, reason: "not yet visible" }`. The caller decides
|
|
212
|
+
* whether to log a warning and proceed (e.g., regtest without an
|
|
213
|
+
* Esplora indexer, or extreme propagation delay) or to escalate.
|
|
214
|
+
* - If no Bitcoin providers are configured → returns `{ verified: false,
|
|
215
|
+
* reason: "no providers" }` immediately.
|
|
216
|
+
*
|
|
217
|
+
* The expected `value` is `targetAmount - networkFee` (what reaches the
|
|
218
|
+
* recipient after the fee), matching the Lit Action's
|
|
219
|
+
* `userReceivesAmount` computation.
|
|
220
|
+
*/
|
|
221
|
+
verifyBroadcastTx(args: {
|
|
222
|
+
txid: string;
|
|
223
|
+
expectedInput: {
|
|
224
|
+
txid: string;
|
|
225
|
+
vout: number;
|
|
226
|
+
};
|
|
227
|
+
expectedOutput: {
|
|
228
|
+
address: string;
|
|
229
|
+
value: number;
|
|
230
|
+
};
|
|
231
|
+
maxAttempts?: number;
|
|
232
|
+
delayMs?: number;
|
|
233
|
+
}): Promise<{
|
|
234
|
+
verified: boolean;
|
|
235
|
+
reason?: string;
|
|
236
|
+
confirmed?: boolean;
|
|
237
|
+
}>;
|
|
238
|
+
/**
|
|
239
|
+
* Get current BTC price using LIT Protocol price oracle.
|
|
240
|
+
*
|
|
241
|
+
* Strict 3-of-3: all three configured providers must respond within 1% of
|
|
242
|
+
* each other, and the median is returned. The previous `mode: "fast" | "full"`
|
|
243
|
+
* parameter (with single-source and lenient-consensus variants) was removed
|
|
244
|
+
* in the H-2 audit fix — there is only one strict path now.
|
|
245
|
+
*
|
|
246
|
+
* @param sign - Whether to request PKP signature on the price
|
|
247
|
+
* @returns BTC price result with timestamp and source
|
|
248
|
+
*/
|
|
249
|
+
getPrice(sign?: boolean): Promise<Result<BTCPriceResult, SDKError>>;
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Factory function to create a BitcoinOperations instance
|
|
253
|
+
*/
|
|
254
|
+
export declare function createBitcoinOperations(config: BitcoinOperationsConfig): Result<BitcoinOperations, SDKError>;
|