mainnet-js 1.0.18 → 1.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/dist/index.html +1 -1
- package/dist/{mainnet-1.0.18.js → mainnet-1.1.0.js} +433 -433
- package/dist/module/network/index.d.ts +2 -0
- package/dist/module/network/index.d.ts.map +1 -1
- package/dist/module/network/index.js +1 -0
- package/dist/module/network/index.js.map +1 -1
- package/dist/module/wallet/Wif.d.ts +2 -2
- package/dist/module/wallet/Wif.d.ts.map +1 -1
- package/dist/module/wallet/Wif.js +4 -11
- package/dist/module/wallet/Wif.js.map +1 -1
- package/dist/module/wallet/model.d.ts +2 -18
- package/dist/module/wallet/model.d.ts.map +1 -1
- package/dist/module/wallet/model.js +29 -35
- package/dist/module/wallet/model.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/Wallet.test.ts +7 -6
- package/src/network/Connection.test.ts +1 -1
- package/src/network/index.ts +2 -0
- package/src/wallet/Util.test.ts +5 -5
- package/src/wallet/Wif.ts +6 -16
- package/src/wallet/model.test.ts +12 -17
- package/src/wallet/model.ts +32 -54
package/src/wallet/model.ts
CHANGED
|
@@ -312,60 +312,6 @@ export class OpReturnData {
|
|
|
312
312
|
|
|
313
313
|
export type SendRequestArray = Array<string | number | UnitEnum | Buffer>;
|
|
314
314
|
|
|
315
|
-
export class UtxoItem {
|
|
316
|
-
index: number;
|
|
317
|
-
value: number;
|
|
318
|
-
utxoId: string;
|
|
319
|
-
txId: string;
|
|
320
|
-
|
|
321
|
-
constructor({
|
|
322
|
-
index,
|
|
323
|
-
value,
|
|
324
|
-
txId,
|
|
325
|
-
}: {
|
|
326
|
-
index: number;
|
|
327
|
-
value: number;
|
|
328
|
-
txId: string;
|
|
329
|
-
}) {
|
|
330
|
-
this.value = value;
|
|
331
|
-
this.txId = txId;
|
|
332
|
-
this.index = index;
|
|
333
|
-
this.utxoId = this.toString();
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
public toString() {
|
|
337
|
-
return [this.txId, this.index, this.value].join(DELIMITER);
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
public static fromId(utxoId: string) {
|
|
341
|
-
let [txid, vout, satoshis] = utxoId.split(DELIMITER);
|
|
342
|
-
return new this({
|
|
343
|
-
txId: txid,
|
|
344
|
-
index: parseInt(vout),
|
|
345
|
-
value: parseInt(satoshis),
|
|
346
|
-
});
|
|
347
|
-
}
|
|
348
|
-
public static fromElectrum(u: UtxoI) {
|
|
349
|
-
return new this({
|
|
350
|
-
txId: u.txid,
|
|
351
|
-
index: u.vout,
|
|
352
|
-
value: u.satoshis,
|
|
353
|
-
});
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
public asElectrum(): UtxoI {
|
|
357
|
-
return {
|
|
358
|
-
txid: this.txId,
|
|
359
|
-
vout: this.index,
|
|
360
|
-
satoshis: this.value,
|
|
361
|
-
} as UtxoI;
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
export class UtxoResponse {
|
|
366
|
-
"utxos"?: Array<UtxoItem>;
|
|
367
|
-
}
|
|
368
|
-
|
|
369
315
|
export class SendResponse {
|
|
370
316
|
txId?: string;
|
|
371
317
|
balance?: BalanceResponse;
|
|
@@ -408,3 +354,35 @@ export class XPubKey {
|
|
|
408
354
|
};
|
|
409
355
|
}
|
|
410
356
|
}
|
|
357
|
+
|
|
358
|
+
export const fromUtxoId = (utxoId: string): UtxoI => {
|
|
359
|
+
const [txid, vout, satoshis, tokenId, amount, capability, commitment] =
|
|
360
|
+
utxoId.split(DELIMITER);
|
|
361
|
+
return {
|
|
362
|
+
satoshis: satoshis ? parseInt(satoshis) : 0,
|
|
363
|
+
vout: parseInt(vout),
|
|
364
|
+
txid,
|
|
365
|
+
token: tokenId
|
|
366
|
+
? {
|
|
367
|
+
tokenId,
|
|
368
|
+
amount: parseInt(amount),
|
|
369
|
+
capability: capability || undefined,
|
|
370
|
+
commitment: commitment || undefined,
|
|
371
|
+
}
|
|
372
|
+
: undefined,
|
|
373
|
+
} as UtxoI;
|
|
374
|
+
};
|
|
375
|
+
|
|
376
|
+
export const toUtxoId = (utxo: UtxoI): string => {
|
|
377
|
+
return [
|
|
378
|
+
utxo.txid,
|
|
379
|
+
utxo.vout,
|
|
380
|
+
utxo.satoshis,
|
|
381
|
+
utxo.token?.tokenId,
|
|
382
|
+
utxo.token?.amount,
|
|
383
|
+
utxo.token?.capability,
|
|
384
|
+
utxo.token?.commitment,
|
|
385
|
+
]
|
|
386
|
+
.join(DELIMITER)
|
|
387
|
+
.replace(/:+$/, "");
|
|
388
|
+
};
|