@bitgo-beta/sdk-coin-kaspa 0.0.1-beta.8 → 0.0.1-beta.80
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/README.md +224 -33
- package/dist/src/kaspa.d.ts +86 -18
- package/dist/src/kaspa.d.ts.map +1 -1
- package/dist/src/kaspa.js +119 -31
- package/dist/src/lib/constants.d.ts +38 -0
- package/dist/src/lib/constants.d.ts.map +1 -1
- package/dist/src/lib/constants.js +56 -5
- package/dist/src/lib/iface.d.ts +28 -17
- package/dist/src/lib/iface.d.ts.map +1 -1
- package/dist/src/lib/iface.js +1 -1
- package/dist/src/lib/index.d.ts +2 -0
- package/dist/src/lib/index.d.ts.map +1 -1
- package/dist/src/lib/index.js +4 -2
- package/dist/src/lib/keyPair.d.ts +6 -2
- package/dist/src/lib/keyPair.d.ts.map +1 -1
- package/dist/src/lib/keyPair.js +7 -4
- package/dist/src/lib/pskt.d.ts +257 -0
- package/dist/src/lib/pskt.d.ts.map +1 -0
- package/dist/src/lib/pskt.js +439 -0
- package/dist/src/lib/sighash.d.ts +34 -13
- package/dist/src/lib/sighash.d.ts.map +1 -1
- package/dist/src/lib/sighash.js +115 -56
- package/dist/src/lib/transaction.d.ts +94 -6
- package/dist/src/lib/transaction.d.ts.map +1 -1
- package/dist/src/lib/transaction.js +199 -21
- package/dist/src/lib/transactionBuilder.d.ts +22 -0
- package/dist/src/lib/transactionBuilder.d.ts.map +1 -1
- package/dist/src/lib/transactionBuilder.js +53 -5
- package/dist/src/lib/transactionBuilderFactory.d.ts +8 -3
- package/dist/src/lib/transactionBuilderFactory.d.ts.map +1 -1
- package/dist/src/lib/transactionBuilderFactory.js +14 -4
- package/dist/src/lib/utils.d.ts +17 -3
- package/dist/src/lib/utils.d.ts.map +1 -1
- package/dist/src/lib/utils.js +45 -11
- package/dist/src/register.js +2 -2
- package/dist/test/fixtures/kaspa.fixtures.d.ts +12 -0
- package/dist/test/fixtures/kaspa.fixtures.d.ts.map +1 -1
- package/dist/test/fixtures/kaspa.fixtures.js +76 -11
- package/dist/test/unit/coin.test.js +129 -9
- package/dist/test/unit/keyPair.test.js +35 -1
- package/dist/test/unit/pskt.test.d.ts +15 -0
- package/dist/test/unit/pskt.test.d.ts.map +1 -0
- package/dist/test/unit/pskt.test.js +383 -0
- package/dist/test/unit/transaction.test.js +291 -11
- package/dist/test/unit/transactionBuilder.test.js +16 -3
- package/dist/test/unit/transactionFlow.test.js +67 -2
- package/dist/test/unit/utils.test.js +63 -4
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +6 -5
package/README.md
CHANGED
|
@@ -17,7 +17,7 @@ Supported coin identifiers:
|
|
|
17
17
|
- Address derivation (kaspa bech32 P2PK Schnorr)
|
|
18
18
|
- UTXO transaction building
|
|
19
19
|
- Schnorr signing and verification (Blake2b-256 sighash)
|
|
20
|
-
- TSS/MPC support (ECDSA algorithm)
|
|
20
|
+
- TSS/MPC support (ECDSA algorithm, per-input DKLS sessions)
|
|
21
21
|
- Full serialization round-trip (hex/JSON)
|
|
22
22
|
|
|
23
23
|
## Installation
|
|
@@ -28,82 +28,273 @@ yarn add @bitgo/sdk-coin-kaspa
|
|
|
28
28
|
|
|
29
29
|
## Usage
|
|
30
30
|
|
|
31
|
-
### Register with BitGo SDK
|
|
31
|
+
### 1. Register with BitGo SDK
|
|
32
32
|
|
|
33
33
|
```typescript
|
|
34
|
+
import { BitGo } from 'bitgo';
|
|
34
35
|
import { register } from '@bitgo/sdk-coin-kaspa';
|
|
36
|
+
|
|
37
|
+
const bitgo = new BitGo({ env: 'prod' });
|
|
35
38
|
register(bitgo);
|
|
39
|
+
|
|
40
|
+
const kaspa = bitgo.coin('kaspa');
|
|
41
|
+
const tkaspa = bitgo.coin('tkaspa'); // testnet
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Alternatively, instantiate directly (useful in tests or scripts):
|
|
45
|
+
|
|
46
|
+
```typescript
|
|
47
|
+
import { Kaspa, Tkaspa } from '@bitgo/sdk-coin-kaspa';
|
|
48
|
+
|
|
49
|
+
const kaspa = Kaspa.createInstance(bitgo);
|
|
50
|
+
const tkaspa = Tkaspa.createInstance(bitgo);
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
### 2. Key Generation
|
|
56
|
+
|
|
57
|
+
```typescript
|
|
58
|
+
// Random key pair
|
|
59
|
+
const kp = kaspa.generateKeyPair();
|
|
60
|
+
console.log(kp.pub); // 66-char hex compressed secp256k1 public key
|
|
61
|
+
console.log(kp.prv); // 64-char hex private key
|
|
62
|
+
|
|
63
|
+
// Deterministic from a 32-byte seed
|
|
64
|
+
const seed = Buffer.from('...32 bytes...', 'hex');
|
|
65
|
+
const kpFromSeed = kaspa.generateKeyPair(seed);
|
|
66
|
+
|
|
67
|
+
// Validation
|
|
68
|
+
kaspa.isValidPub(kp.pub); // true
|
|
69
|
+
kaspa.isValidPrv(kp.prv); // true
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Using `KeyPair` directly:
|
|
73
|
+
|
|
74
|
+
```typescript
|
|
75
|
+
import { KeyPair } from '@bitgo/sdk-coin-kaspa';
|
|
76
|
+
|
|
77
|
+
const keyPair = new KeyPair(); // random
|
|
78
|
+
const { pub, prv } = keyPair.getKeys();
|
|
36
79
|
```
|
|
37
80
|
|
|
38
|
-
|
|
81
|
+
---
|
|
82
|
+
|
|
83
|
+
### 3. Address Generation
|
|
39
84
|
|
|
40
85
|
```typescript
|
|
41
86
|
import { KeyPair } from '@bitgo/sdk-coin-kaspa';
|
|
42
87
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
const
|
|
88
|
+
const keyPair = new KeyPair({ prv: '<64-char-hex-private-key>' });
|
|
89
|
+
|
|
90
|
+
const mainnetAddress = keyPair.getAddress('mainnet'); // kaspa:qq...
|
|
91
|
+
const testnetAddress = keyPair.getAddress('testnet'); // kaspatest:qq...
|
|
92
|
+
|
|
93
|
+
kaspa.isValidAddress(mainnetAddress); // true
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Computing the P2PK `scriptPublicKey` for a key (required when constructing UTXO inputs):
|
|
46
97
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
98
|
+
```typescript
|
|
99
|
+
import { compressedToXOnly, buildP2PKScriptPublicKey } from '@bitgo/sdk-coin-kaspa';
|
|
100
|
+
|
|
101
|
+
const xOnlyPub = compressedToXOnly(Buffer.from(pub, 'hex'));
|
|
102
|
+
const scriptPublicKey = buildP2PKScriptPublicKey(xOnlyPub).toString('hex');
|
|
50
103
|
```
|
|
51
104
|
|
|
52
|
-
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
### 4. Building a Transaction
|
|
53
108
|
|
|
54
109
|
```typescript
|
|
55
|
-
import { TransactionBuilderFactory } from '@bitgo/sdk-coin-kaspa';
|
|
110
|
+
import { TransactionBuilderFactory, Transaction } from '@bitgo/sdk-coin-kaspa';
|
|
56
111
|
import { coins } from '@bitgo/statics';
|
|
112
|
+
import type { KaspaUtxoInput } from '@bitgo/sdk-coin-kaspa';
|
|
113
|
+
|
|
114
|
+
const utxo: KaspaUtxoInput = {
|
|
115
|
+
transactionId: '<64-char-hex-prev-tx-id>',
|
|
116
|
+
transactionIndex: 0,
|
|
117
|
+
amount: '100000000', // 1 KASPA in sompi (1e8)
|
|
118
|
+
scriptPublicKey: '<hex>', // P2PK script of the sender's key
|
|
119
|
+
sequence: '0',
|
|
120
|
+
sigOpCount: 1,
|
|
121
|
+
};
|
|
57
122
|
|
|
58
123
|
const factory = new TransactionBuilderFactory(coins.get('kaspa'));
|
|
59
124
|
const builder = factory.getBuilder();
|
|
60
125
|
|
|
61
126
|
builder
|
|
62
|
-
.addInput(
|
|
63
|
-
|
|
64
|
-
transactionIndex: 0,
|
|
65
|
-
amount: '100000000', // 1 KASPA in sompi
|
|
66
|
-
scriptPublicKey: '<spk>',
|
|
67
|
-
sequence: '0',
|
|
68
|
-
sigOpCount: 1,
|
|
69
|
-
})
|
|
70
|
-
.to('<recipient-kaspa-address>', '99998000')
|
|
127
|
+
.addInput(utxo)
|
|
128
|
+
.to('kaspa:qq...recipient...', '99998000') // amount in sompi
|
|
71
129
|
.fee('2000');
|
|
72
130
|
|
|
73
|
-
const tx = await builder.build();
|
|
131
|
+
const tx = (await builder.build()) as Transaction;
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
Multiple inputs:
|
|
135
|
+
|
|
136
|
+
```typescript
|
|
137
|
+
builder
|
|
138
|
+
.addInput(utxo1)
|
|
139
|
+
.addInput(utxo2)
|
|
140
|
+
.to(recipientAddress, '299996000')
|
|
141
|
+
.fee('4000');
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
---
|
|
145
|
+
|
|
146
|
+
### 5. Signing — Path A: Direct Private Key (non-TSS)
|
|
147
|
+
|
|
148
|
+
```typescript
|
|
149
|
+
// `tx.sign` takes a 32-byte Buffer (raw private key)
|
|
74
150
|
tx.sign(Buffer.from(privateKeyHex, 'hex'));
|
|
75
151
|
|
|
76
|
-
|
|
152
|
+
// Signs every input at once. Fully signed → txHex; partial → halfSigned
|
|
153
|
+
const signedTxHex = tx.toHex(); // SDK-internal format for round-trips
|
|
154
|
+
|
|
155
|
+
// Or via the coin interface:
|
|
156
|
+
const result = await kaspa.signTransaction({
|
|
157
|
+
txPrebuild: { txHex: unsignedTxHex },
|
|
158
|
+
prv: privateKeyHex,
|
|
159
|
+
} as any) as { txHex: string };
|
|
77
160
|
```
|
|
78
161
|
|
|
162
|
+
---
|
|
163
|
+
|
|
164
|
+
### 6. Signing — Path B: TSS / MPC (per-input DKLS sessions)
|
|
165
|
+
|
|
166
|
+
Kaspa is UTXO-based: every input has its own sighash (Blake2b-256, BIP-143-like).
|
|
167
|
+
Each input **requires an independent DKLS session** — there is no way to produce N valid
|
|
168
|
+
Schnorr signatures from a single signing operation.
|
|
169
|
+
|
|
170
|
+
```typescript
|
|
171
|
+
const unsignedTx = (await builder.build()) as Transaction;
|
|
172
|
+
const txHex = unsignedTx.toHex();
|
|
173
|
+
|
|
174
|
+
// Step 1: one sighash Buffer per input — the messages for each DKLS session
|
|
175
|
+
const sighashes: Buffer[] = unsignedTx.signablePayloads; // Buffer[N]
|
|
176
|
+
|
|
177
|
+
// Step 2: run N DKLS sessions in parallel (one per sighash)
|
|
178
|
+
// Each session produces a 64-byte raw Schnorr signature
|
|
179
|
+
|
|
180
|
+
// Step 3: collect results and call signTransaction
|
|
181
|
+
const signatures = sighashes.map((hash, inputIndex) => ({
|
|
182
|
+
inputIndex,
|
|
183
|
+
pubKey: compressedPubKeyHex, // 33-byte hex
|
|
184
|
+
signature: dklsSession(hash), // 64-byte hex Schnorr sig
|
|
185
|
+
}));
|
|
186
|
+
|
|
187
|
+
const result = await kaspa.signTransaction({
|
|
188
|
+
txPrebuild: { txHex },
|
|
189
|
+
signatures,
|
|
190
|
+
} as any) as { txHex: string } | { halfSigned: { txHex: string } };
|
|
191
|
+
|
|
192
|
+
// result.txHex → all inputs signed
|
|
193
|
+
// result.halfSigned → some inputs still unsigned (partial TSS round)
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
---
|
|
197
|
+
|
|
198
|
+
### 7. Broadcasting
|
|
199
|
+
|
|
200
|
+
```typescript
|
|
201
|
+
// toBroadcastFormat() returns the Kaspa RPC-compatible JSON string
|
|
202
|
+
const broadcastPayload = tx.toBroadcastFormat();
|
|
203
|
+
|
|
204
|
+
// toHex() is the SDK-internal round-trip format (preserves amount + scriptPublicKey
|
|
205
|
+
// on inputs for sighash recomputation). Do NOT send this to the Kaspa node directly.
|
|
206
|
+
const internalHex = tx.toHex();
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
---
|
|
210
|
+
|
|
211
|
+
### 8. Explaining / Parsing a Transaction
|
|
212
|
+
|
|
213
|
+
```typescript
|
|
214
|
+
// Human-readable breakdown
|
|
215
|
+
const explained = await kaspa.explainTransaction({ txHex });
|
|
216
|
+
console.log(explained.outputs); // [{ address, amount }]
|
|
217
|
+
console.log(explained.outputAmount); // total sent (sompi)
|
|
218
|
+
console.log(explained.fee); // fee (sompi)
|
|
219
|
+
|
|
220
|
+
// Structured parse — inputs and outputs tagged with coin name
|
|
221
|
+
const parsed = await kaspa.parseTransaction({ txHex } as any);
|
|
222
|
+
// { inputs: [{ amount, coin: 'kaspa' }], outputs: [{ address, amount, coin: 'kaspa' }] }
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
---
|
|
226
|
+
|
|
227
|
+
### 9. Verifying a Transaction
|
|
228
|
+
|
|
229
|
+
```typescript
|
|
230
|
+
const valid = await kaspa.verifyTransaction({
|
|
231
|
+
txPrebuild: { txHex },
|
|
232
|
+
txParams: {
|
|
233
|
+
recipients: [{ address: 'kaspa:qq...', amount: '99998000' }],
|
|
234
|
+
},
|
|
235
|
+
} as any);
|
|
236
|
+
|
|
237
|
+
console.log(valid); // true
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
---
|
|
241
|
+
|
|
242
|
+
### 10. Coin Properties
|
|
243
|
+
|
|
244
|
+
```typescript
|
|
245
|
+
kaspa.getChain(); // 'kaspa'
|
|
246
|
+
kaspa.getFamily(); // 'kaspa'
|
|
247
|
+
kaspa.getFullName(); // 'Kaspa'
|
|
248
|
+
kaspa.getBaseFactor(); // 100_000_000 (sompi per KASPA)
|
|
249
|
+
kaspa.supportsTss(); // true
|
|
250
|
+
kaspa.getMPCAlgorithm(); // 'ecdsa'
|
|
251
|
+
|
|
252
|
+
tkaspa.getChain(); // 'tkaspa'
|
|
253
|
+
tkaspa.getFullName(); // 'Testnet Kaspa'
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
---
|
|
257
|
+
|
|
258
|
+
## Key Constants
|
|
259
|
+
|
|
260
|
+
| Property | Value |
|
|
261
|
+
|---|---|
|
|
262
|
+
| 1 KASPA | `100_000_000` sompi |
|
|
263
|
+
| `getBaseFactor()` | `1e8` |
|
|
264
|
+
| Mainnet address prefix | `kaspa:` |
|
|
265
|
+
| Testnet address prefix | `kaspatest:` |
|
|
266
|
+
| Address type | P2PK Schnorr (x-only secp256k1) |
|
|
267
|
+
| Signature algorithm | Schnorr (Blake2b-256 sighash) |
|
|
268
|
+
| TSS algorithm | `ecdsa` (DKLS) |
|
|
269
|
+
| Multisig type | `onchain` |
|
|
270
|
+
|
|
271
|
+
---
|
|
272
|
+
|
|
79
273
|
## Module Structure
|
|
80
274
|
|
|
81
275
|
```
|
|
82
276
|
src/
|
|
83
|
-
├── kaspa.ts # Kaspa
|
|
84
|
-
├──
|
|
85
|
-
├── register.ts # SDK registration
|
|
277
|
+
├── kaspa.ts # AbstractKaspaLikeCoin, Kaspa, Tkaspa classes
|
|
278
|
+
├── register.ts # SDK registration helper
|
|
86
279
|
├── index.ts
|
|
87
280
|
└── lib/
|
|
88
|
-
├── constants.ts # Chain constants (prefixes, decimals,
|
|
281
|
+
├── constants.ts # Chain constants (prefixes, decimals, default fee)
|
|
89
282
|
├── iface.ts # TypeScript interfaces
|
|
90
|
-
├── keyPair.ts # secp256k1 key pair
|
|
91
|
-
├── sighash.ts # Blake2b-256 Schnorr sighash
|
|
92
|
-
├── transaction.ts # Transaction class (sign/verify/explain)
|
|
283
|
+
├── keyPair.ts # secp256k1 key pair + address derivation
|
|
284
|
+
├── sighash.ts # Blake2b-256 Schnorr sighash + script utilities
|
|
285
|
+
├── transaction.ts # Transaction class (sign / verify / explain / serialize)
|
|
93
286
|
├── transactionBuilder.ts # UTXO transaction builder
|
|
94
287
|
├── transactionBuilderFactory.ts
|
|
95
288
|
├── utils.ts # Address validation and encoding
|
|
96
289
|
└── index.ts
|
|
97
290
|
test/
|
|
98
291
|
├── fixtures/
|
|
99
|
-
│
|
|
100
|
-
│ └── kaspaFixtures.ts # Synthetic test fixtures
|
|
292
|
+
│ └── kaspa.fixtures.ts # Deterministic test vectors
|
|
101
293
|
└── unit/
|
|
102
294
|
├── coin.test.ts
|
|
103
295
|
├── keyPair.test.ts
|
|
104
296
|
├── transaction.test.ts
|
|
105
297
|
├── transactionBuilder.test.ts
|
|
106
|
-
├── transactionFlow.test.ts
|
|
107
298
|
└── utils.test.ts
|
|
108
299
|
```
|
|
109
300
|
|
|
@@ -117,7 +308,7 @@ Kaspa uses a custom cashaddr-like bech32 encoding:
|
|
|
117
308
|
|
|
118
309
|
## Signing
|
|
119
310
|
|
|
120
|
-
Kaspa uses **Schnorr signatures over secp256k1** with a **Blake2b-256** sighash. The sighash preimage follows the Kaspa BIP-143-like specification. Each input is signed independently, producing a 65-byte signature: 64 bytes Schnorr + 1 byte sighash type.
|
|
311
|
+
Kaspa uses **Schnorr signatures over secp256k1** with a **Blake2b-256** sighash. The sighash preimage follows the Kaspa BIP-143-like specification. Each input is signed independently, producing a 65-byte signature: 64 bytes Schnorr + 1 byte sighash type (`0x01` = SIGHASH_ALL).
|
|
121
312
|
|
|
122
313
|
## References
|
|
123
314
|
|
package/dist/src/kaspa.d.ts
CHANGED
|
@@ -1,18 +1,35 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
export declare class
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import { AuditDecryptedKeyParams, BitGoBase, IWallet, KeyPair as IKeyPair, MPCAlgorithm, MultisigType, SignedTransaction, VerifyAddressOptions } from '@bitgo-beta/sdk-core';
|
|
2
|
+
import { AbstractUtxoCoin, ExplainTransactionOptions, ParseTransactionOptions, SignTransactionOptions, TransactionPrebuild, UtxoCoinName, UtxoCoinNameMainnet, transaction } from '@bitgo-beta/abstract-utxo';
|
|
3
|
+
import { KaspaVerifyTransactionOptions } from './lib/iface';
|
|
4
|
+
export declare abstract class AbstractKaspaLikeCoin extends AbstractUtxoCoin {
|
|
5
|
+
/**
|
|
6
|
+
* Kaspa has no utxo-lib network entry. This deprecated getter is overridden
|
|
7
|
+
* to prevent accidental usage of the Bitcoin PSBT signing stack.
|
|
8
|
+
*/
|
|
9
|
+
get network(): never;
|
|
10
|
+
/**
|
|
11
|
+
* Kaspa family name is 'kaspa' for both mainnet and testnet.
|
|
12
|
+
* Override avoids going through names.ts which only knows Bitcoin-family coins.
|
|
13
|
+
* The cast is required because UtxoCoinNameMainnet is a closed union of Bitcoin-family coins;
|
|
14
|
+
* Kaspa manages its own network stack and is intentionally outside that union.
|
|
15
|
+
*/
|
|
16
|
+
getFamily(): UtxoCoinNameMainnet;
|
|
17
|
+
/**
|
|
18
|
+
* Human-readable name for this coin variant.
|
|
19
|
+
* Implemented in each concrete class to avoid runtime name comparisons.
|
|
20
|
+
*/
|
|
21
|
+
abstract getFullName(): string;
|
|
22
|
+
/**
|
|
23
|
+
* Whether this is a mainnet or testnet coin.
|
|
24
|
+
* Implemented in each concrete class to avoid runtime name comparisons.
|
|
25
|
+
*/
|
|
26
|
+
protected abstract isMainnet(): boolean;
|
|
27
|
+
supportsBlockTarget(): boolean;
|
|
11
28
|
/**
|
|
12
29
|
* Return the base factor (sompi per KASPA).
|
|
13
30
|
* 1 KASPA = 100,000,000 sompi (8 decimal places)
|
|
14
31
|
*/
|
|
15
|
-
getBaseFactor():
|
|
32
|
+
getBaseFactor(): number;
|
|
16
33
|
/** @inheritDoc */
|
|
17
34
|
getDefaultMultisigType(): MultisigType;
|
|
18
35
|
/**
|
|
@@ -30,7 +47,10 @@ export declare class Kaspa extends BaseCoin {
|
|
|
30
47
|
/**
|
|
31
48
|
* Generate a Kaspa key pair.
|
|
32
49
|
*/
|
|
33
|
-
generateKeyPair(seed?: Buffer):
|
|
50
|
+
generateKeyPair(seed?: Buffer): {
|
|
51
|
+
pub: string;
|
|
52
|
+
prv: string;
|
|
53
|
+
};
|
|
34
54
|
/**
|
|
35
55
|
* Check if address belongs to wallet by deriving from keychains.
|
|
36
56
|
*/
|
|
@@ -38,27 +58,75 @@ export declare class Kaspa extends BaseCoin {
|
|
|
38
58
|
private getBuilder;
|
|
39
59
|
/**
|
|
40
60
|
* Parse a Kaspa transaction from prebuild.
|
|
61
|
+
* Overrides AbstractUtxoCoin's PSBT-based implementation with Kaspa's JSON-hex format.
|
|
41
62
|
*/
|
|
42
|
-
parseTransaction(params: ParseTransactionOptions): Promise<ParsedTransaction
|
|
63
|
+
parseTransaction<TNumber extends number | bigint = number>(params: ParseTransactionOptions<TNumber>): Promise<transaction.ParsedTransaction<TNumber>>;
|
|
43
64
|
/**
|
|
44
65
|
* Verify a Kaspa transaction against expected params.
|
|
45
66
|
*/
|
|
46
67
|
verifyTransaction(params: KaspaVerifyTransactionOptions): Promise<boolean>;
|
|
47
68
|
/**
|
|
48
69
|
* Explain a Kaspa transaction.
|
|
70
|
+
* Overrides AbstractUtxoCoin's PSBT-based implementation with Kaspa's JSON-hex format.
|
|
71
|
+
* The return type cast is necessary because Kaspa uses a custom TransactionExplanation
|
|
72
|
+
* that doesn't include Bitcoin-specific fields (chain, index) on outputs.
|
|
49
73
|
*/
|
|
50
|
-
explainTransaction(params:
|
|
74
|
+
explainTransaction<TNumber extends number | bigint = number>(params: ExplainTransactionOptions<TNumber>, _wallet?: IWallet): Promise<Awaited<ReturnType<AbstractUtxoCoin['explainTransaction']>>>;
|
|
51
75
|
/**
|
|
52
76
|
* Sign a Kaspa transaction using secp256k1 Schnorr signatures.
|
|
77
|
+
*
|
|
78
|
+
* Kaspa is a UTXO coin: every input has its own sighash.
|
|
79
|
+
* Two signing paths are supported:
|
|
80
|
+
*
|
|
81
|
+
* Path A — `params.prv` (direct key, test / non-TSS):
|
|
82
|
+
* Calls `tx.sign(prv)` which loops every input and produces a Schnorr
|
|
83
|
+
* signature for each one in a single call.
|
|
84
|
+
*
|
|
85
|
+
* Path B — `params.signatures` (TSS multi-input):
|
|
86
|
+
* The caller already ran one independent DKLS session per input, using
|
|
87
|
+
* `tx.signablePayloads[i]` as the message for session i. Each resulting
|
|
88
|
+
* signature is applied to its input via `addSignatureForInput`.
|
|
89
|
+
*
|
|
90
|
+
* Platform flow:
|
|
91
|
+
* 1. Build tx, read `(tx as Transaction).signablePayloads` → Buffer[N]
|
|
92
|
+
* 2. Run N DKLS sessions in parallel, one per sighash
|
|
93
|
+
* 3. Call signTransaction({ signatures: [{ inputIndex, pubKey, signature }, ...] })
|
|
94
|
+
*/
|
|
95
|
+
signTransaction<TNumber extends number | bigint = number>(params: SignTransactionOptions<TNumber>): Promise<SignedTransaction>;
|
|
96
|
+
/**
|
|
97
|
+
* Kaspa's txHex is already the custom JSON-hex format — skip the PSBT
|
|
98
|
+
* re-encode that AbstractUtxoCoin.postProcessPrebuild would otherwise apply.
|
|
53
99
|
*/
|
|
54
|
-
|
|
55
|
-
signMessage(
|
|
100
|
+
postProcessPrebuild<TNumber extends number | bigint>(prebuild: TransactionPrebuild<TNumber>): Promise<TransactionPrebuild<TNumber>>;
|
|
101
|
+
signMessage(_key: IKeyPair, _message: string | Buffer): Promise<Buffer>;
|
|
56
102
|
/** @inheritDoc */
|
|
57
|
-
auditDecryptedKey(
|
|
103
|
+
auditDecryptedKey(_params: AuditDecryptedKeyParams): void;
|
|
58
104
|
/**
|
|
59
|
-
* MPC support: Kaspa uses secp256k1 (Schnorr variant
|
|
105
|
+
* TSS/MPC support: Kaspa uses secp256k1 (Schnorr variant for on-chain,
|
|
106
|
+
* ECDSA for the off-chain TSS ceremony).
|
|
107
|
+
*
|
|
108
|
+
* Kaspa is a UTXO coin with a BIP-143-like per-input sighash scheme.
|
|
109
|
+
* Each input commits to its own index and produces a distinct hash.
|
|
110
|
+
* One independent DKLS signing session is required per input.
|
|
111
|
+
*
|
|
112
|
+
* Correct multi-input TSS flow:
|
|
113
|
+
* 1. Read `tx.signablePayloads` → Buffer[] (one sighash per input).
|
|
114
|
+
* 2. Run one DKLS signing session per sighash IN PARALLEL.
|
|
115
|
+
* 3. Apply each signature: `tx.addSignatureForInput(i, pubKey, sig)`.
|
|
60
116
|
*/
|
|
61
117
|
supportsTss(): boolean;
|
|
62
118
|
getMPCAlgorithm(): MPCAlgorithm;
|
|
63
119
|
}
|
|
120
|
+
export declare class Kaspa extends AbstractKaspaLikeCoin {
|
|
121
|
+
readonly name: UtxoCoinName;
|
|
122
|
+
getFullName(): string;
|
|
123
|
+
protected isMainnet(): boolean;
|
|
124
|
+
static createInstance(bitgo: BitGoBase): Kaspa;
|
|
125
|
+
}
|
|
126
|
+
export declare class Tkaspa extends AbstractKaspaLikeCoin {
|
|
127
|
+
readonly name: UtxoCoinName;
|
|
128
|
+
getFullName(): string;
|
|
129
|
+
protected isMainnet(): boolean;
|
|
130
|
+
static createInstance(bitgo: BitGoBase): Tkaspa;
|
|
131
|
+
}
|
|
64
132
|
//# sourceMappingURL=kaspa.d.ts.map
|
package/dist/src/kaspa.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kaspa.d.ts","sourceRoot":"","sources":["../../src/kaspa.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"kaspa.d.ts","sourceRoot":"","sources":["../../src/kaspa.ts"],"names":[],"mappings":"AACA,OAAO,EACL,uBAAuB,EACvB,SAAS,EACT,OAAO,EAGP,OAAO,IAAI,QAAQ,EAEnB,YAAY,EACZ,YAAY,EAEZ,iBAAiB,EAEjB,oBAAoB,EACrB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,gBAAgB,EAChB,yBAAyB,EACzB,uBAAuB,EACvB,sBAAsB,EACtB,mBAAmB,EACnB,YAAY,EACZ,mBAAmB,EACnB,WAAW,EACZ,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAA+B,6BAA6B,EAAE,MAAM,aAAa,CAAC;AAGzF,8BAAsB,qBAAsB,SAAQ,gBAAgB;IAClE;;;OAGG;IACH,IAAI,OAAO,IAAI,KAAK,CAEnB;IAED;;;;;OAKG;IACH,SAAS,IAAI,mBAAmB;IAIhC;;;OAGG;IACH,QAAQ,CAAC,WAAW,IAAI,MAAM;IAE9B;;;OAGG;IACH,SAAS,CAAC,QAAQ,CAAC,SAAS,IAAI,OAAO;IAE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