utxo-lib 1.1.3 → 1.1.5
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/src/address.d.ts.map +1 -1
- package/dist/src/address.js +1 -11
- package/dist/src/addressFormat.d.ts +1 -1
- package/dist/src/addressFormat.d.ts.map +1 -1
- package/dist/src/addressFormat.js +1 -1
- package/dist/src/bitgo/Musig2.d.ts +17 -115
- package/dist/src/bitgo/Musig2.d.ts.map +1 -1
- package/dist/src/bitgo/Musig2.js +101 -283
- package/dist/src/bitgo/UtxoPsbt.d.ts +49 -173
- package/dist/src/bitgo/UtxoPsbt.d.ts.map +1 -1
- package/dist/src/bitgo/UtxoPsbt.js +112 -634
- package/dist/src/bitgo/bbc/DashPsbt.d.ts +12 -0
- package/dist/src/bitgo/bbc/DashPsbt.d.ts.map +1 -0
- package/dist/src/bitgo/bbc/DashPsbt.js +27 -0
- package/dist/src/bitgo/bbc/DashTransaction.d.ts +39 -0
- package/dist/src/bitgo/bbc/DashTransaction.d.ts.map +1 -0
- package/dist/src/bitgo/bbc/DashTransaction.js +109 -0
- package/dist/src/bitgo/bbc/DashTransactionBuilder.d.ts +14 -0
- package/dist/src/bitgo/bbc/DashTransactionBuilder.d.ts.map +1 -0
- package/dist/src/bitgo/bbc/DashTransactionBuilder.js +28 -0
- package/dist/src/bitgo/bbc/index.d.ts +4 -0
- package/dist/src/bitgo/bbc/index.d.ts.map +1 -0
- package/dist/src/bitgo/{litecoin → bbc}/index.js +4 -4
- package/dist/src/bitgo/bitcoincash/address.js +2 -2
- package/dist/src/bitgo/index.d.ts +0 -10
- package/dist/src/bitgo/index.d.ts.map +1 -1
- package/dist/src/bitgo/index.js +2 -5
- package/dist/src/bitgo/outputScripts.d.ts +1 -3
- package/dist/src/bitgo/outputScripts.d.ts.map +1 -1
- package/dist/src/bitgo/outputScripts.js +10 -18
- package/dist/src/bitgo/parseInput.d.ts +20 -49
- package/dist/src/bitgo/parseInput.d.ts.map +1 -1
- package/dist/src/bitgo/parseInput.js +24 -108
- package/dist/src/bitgo/psbt/fromHalfSigned.d.ts.map +1 -1
- package/dist/src/bitgo/psbt/fromHalfSigned.js +6 -9
- package/dist/src/bitgo/signature.d.ts +3 -3
- package/dist/src/bitgo/signature.d.ts.map +1 -1
- package/dist/src/bitgo/signature.js +16 -48
- package/dist/src/bitgo/transaction.d.ts +3 -18
- package/dist/src/bitgo/transaction.d.ts.map +1 -1
- package/dist/src/bitgo/transaction.js +15 -28
- package/dist/src/bitgo/types.d.ts +0 -2
- package/dist/src/bitgo/types.d.ts.map +1 -1
- package/dist/src/bitgo/types.js +1 -1
- package/dist/src/bitgo/wallet/Psbt.d.ts +12 -90
- package/dist/src/bitgo/wallet/Psbt.d.ts.map +1 -1
- package/dist/src/bitgo/wallet/Psbt.js +71 -221
- package/dist/src/bitgo/wallet/Unspent.d.ts +0 -28
- package/dist/src/bitgo/wallet/Unspent.d.ts.map +1 -1
- package/dist/src/bitgo/wallet/Unspent.js +68 -173
- package/dist/src/bitgo/wallet/chains.d.ts +2 -2
- package/dist/src/bitgo/wallet/chains.d.ts.map +1 -1
- package/dist/src/bitgo/wallet/chains.js +1 -1
- package/dist/src/bitgo/zcash/ZcashPsbt.d.ts.map +1 -1
- package/dist/src/bitgo/zcash/ZcashPsbt.js +3 -4
- package/dist/src/networks.d.ts +2 -1
- package/dist/src/networks.d.ts.map +1 -1
- package/dist/src/networks.js +29 -22
- package/dist/src/noble_ecc.d.ts.map +1 -1
- package/dist/src/noble_ecc.js +2 -6
- package/dist/src/payments/p2tr.d.ts.map +1 -1
- package/dist/src/payments/p2tr.js +9 -15
- package/dist/src/taproot.d.ts +0 -16
- package/dist/src/taproot.d.ts.map +1 -1
- package/dist/src/taproot.js +2 -44
- package/dist/src/testutil/index.d.ts +0 -2
- package/dist/src/testutil/index.d.ts.map +1 -1
- package/dist/src/testutil/index.js +1 -3
- package/dist/src/testutil/mock.d.ts +1 -1
- package/dist/src/testutil/mock.d.ts.map +1 -1
- package/dist/src/testutil/mock.js +4 -12
- package/package.json +3 -5
- package/dist/src/bitgo/PsbtUtil.d.ts +0 -54
- package/dist/src/bitgo/PsbtUtil.d.ts.map +0 -1
- package/dist/src/bitgo/PsbtUtil.js +0 -79
- package/dist/src/bitgo/litecoin/LitecoinPsbt.d.ts +0 -10
- package/dist/src/bitgo/litecoin/LitecoinPsbt.d.ts.map +0 -1
- package/dist/src/bitgo/litecoin/LitecoinPsbt.js +0 -17
- package/dist/src/bitgo/litecoin/LitecoinTransaction.d.ts +0 -16
- package/dist/src/bitgo/litecoin/LitecoinTransaction.d.ts.map +0 -1
- package/dist/src/bitgo/litecoin/LitecoinTransaction.js +0 -46
- package/dist/src/bitgo/litecoin/LitecoinTransactionBuilder.d.ts +0 -10
- package/dist/src/bitgo/litecoin/LitecoinTransactionBuilder.d.ts.map +0 -1
- package/dist/src/bitgo/litecoin/LitecoinTransactionBuilder.js +0 -15
- package/dist/src/bitgo/litecoin/index.d.ts +0 -4
- package/dist/src/bitgo/litecoin/index.d.ts.map +0 -1
- package/dist/src/testutil/psbt.d.ts +0 -71
- package/dist/src/testutil/psbt.d.ts.map +0 -1
- package/dist/src/testutil/psbt.js +0 -147
- package/dist/src/testutil/transaction.d.ts +0 -61
- package/dist/src/testutil/transaction.d.ts.map +0 -1
- package/dist/src/testutil/transaction.js +0 -107
@@ -1,16 +0,0 @@
|
|
1
|
-
/// <reference types="node" />
|
2
|
-
import { UtxoTransaction } from '../UtxoTransaction';
|
3
|
-
import { Network, networks } from '../../networks';
|
4
|
-
export declare type LitecoinNetwork = typeof networks.litecoin | typeof networks.litecoinTest;
|
5
|
-
/**
|
6
|
-
* We only care about reading a transaction that can have a potentially different advanced transaction flag,
|
7
|
-
* but we dont need to write one.
|
8
|
-
*/
|
9
|
-
export declare class LitecoinTransaction<TNumber extends number | bigint = number> extends UtxoTransaction<TNumber> {
|
10
|
-
static MWEB_PEGOUT_TX_FLAG: number;
|
11
|
-
constructor(network: Network, tx?: LitecoinTransaction<bigint | number>, amountType?: 'bigint' | 'number');
|
12
|
-
protected static newTransaction<TNumber extends number | bigint = number>(network: Network, transaction?: LitecoinTransaction<number | bigint>, amountType?: 'number' | 'bigint'): LitecoinTransaction<TNumber>;
|
13
|
-
clone<TN2 extends bigint | number = TNumber>(amountType?: 'number' | 'bigint'): LitecoinTransaction<TN2>;
|
14
|
-
static fromBuffer<TNumber extends number | bigint = number>(buffer: Buffer, noStrict: boolean, amountType?: 'number' | 'bigint', network?: LitecoinNetwork): LitecoinTransaction<TNumber>;
|
15
|
-
}
|
16
|
-
//# sourceMappingURL=LitecoinTransaction.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"LitecoinTransaction.d.ts","sourceRoot":"","sources":["../../../../src/bitgo/litecoin/LitecoinTransaction.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAc,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE/D,oBAAY,eAAe,GAAG,OAAO,QAAQ,CAAC,QAAQ,GAAG,OAAO,QAAQ,CAAC,YAAY,CAAC;AAEtF;;;GAGG;AACH,qBAAa,mBAAmB,CAAC,OAAO,SAAS,MAAM,GAAG,MAAM,GAAG,MAAM,CAAE,SAAQ,eAAe,CAAC,OAAO,CAAC;IACzG,MAAM,CAAC,mBAAmB,SAAQ;gBAEtB,OAAO,EAAE,OAAO,EAAE,EAAE,CAAC,EAAE,mBAAmB,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,UAAU,CAAC,EAAE,QAAQ,GAAG,QAAQ;IAQzG,SAAS,CAAC,MAAM,CAAC,cAAc,CAAC,OAAO,SAAS,MAAM,GAAG,MAAM,GAAG,MAAM,EACtE,OAAO,EAAE,OAAO,EAChB,WAAW,CAAC,EAAE,mBAAmB,CAAC,MAAM,GAAG,MAAM,CAAC,EAClD,UAAU,CAAC,EAAE,QAAQ,GAAG,QAAQ,GAC/B,mBAAmB,CAAC,OAAO,CAAC;IAI/B,KAAK,CAAC,GAAG,SAAS,MAAM,GAAG,MAAM,GAAG,OAAO,EAAE,UAAU,CAAC,EAAE,QAAQ,GAAG,QAAQ,GAAG,mBAAmB,CAAC,GAAG,CAAC;IAIxG,MAAM,CAAC,UAAU,CAAC,OAAO,SAAS,MAAM,GAAG,MAAM,GAAG,MAAM,EACxD,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,OAAO,EACjB,UAAU,GAAE,QAAQ,GAAG,QAAmB,EAC1C,OAAO,CAAC,EAAE,eAAe,GACxB,mBAAmB,CAAC,OAAO,CAAC;CAuBhC"}
|
@@ -1,46 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.LitecoinTransaction = void 0;
|
4
|
-
const bufferutils_1 = require("bitcoinjs-lib/src/bufferutils");
|
5
|
-
const UtxoTransaction_1 = require("../UtxoTransaction");
|
6
|
-
const networks_1 = require("../../networks");
|
7
|
-
/**
|
8
|
-
* We only care about reading a transaction that can have a potentially different advanced transaction flag,
|
9
|
-
* but we dont need to write one.
|
10
|
-
*/
|
11
|
-
class LitecoinTransaction extends UtxoTransaction_1.UtxoTransaction {
|
12
|
-
constructor(network, tx, amountType) {
|
13
|
-
super(network, tx, amountType);
|
14
|
-
if (!networks_1.isLitecoin(network)) {
|
15
|
-
throw new Error(`invalid network`);
|
16
|
-
}
|
17
|
-
}
|
18
|
-
static newTransaction(network, transaction, amountType) {
|
19
|
-
return new LitecoinTransaction(network, transaction, amountType);
|
20
|
-
}
|
21
|
-
clone(amountType) {
|
22
|
-
return new LitecoinTransaction(this.network, this, amountType);
|
23
|
-
}
|
24
|
-
static fromBuffer(buffer, noStrict, amountType = 'number', network) {
|
25
|
-
if (!network) {
|
26
|
-
throw new Error(`must provide network`);
|
27
|
-
}
|
28
|
-
const bufferReader = new bufferutils_1.BufferReader(buffer);
|
29
|
-
const txVersion = bufferReader.readInt32();
|
30
|
-
const marker = bufferReader.readUInt8();
|
31
|
-
const flag = bufferReader.readUInt8();
|
32
|
-
if (marker === LitecoinTransaction.ADVANCED_TRANSACTION_MARKER &&
|
33
|
-
flag === LitecoinTransaction.MWEB_PEGOUT_TX_FLAG) {
|
34
|
-
// Litecoin has an MWEB advanced transaction marker. Slice out the marker and 5th to last byte and read like a normal transaction
|
35
|
-
const bufferWriter = new bufferutils_1.BufferWriter(Buffer.allocUnsafe(buffer.length - 3));
|
36
|
-
bufferWriter.writeUInt32(txVersion);
|
37
|
-
bufferWriter.writeSlice(buffer.slice(6, buffer.length - 5));
|
38
|
-
bufferWriter.writeSlice(buffer.slice(buffer.length - 4, buffer.length));
|
39
|
-
return super.fromBuffer(bufferWriter.buffer, noStrict, amountType, network);
|
40
|
-
}
|
41
|
-
return super.fromBuffer(buffer, noStrict, amountType, network);
|
42
|
-
}
|
43
|
-
}
|
44
|
-
exports.LitecoinTransaction = LitecoinTransaction;
|
45
|
-
LitecoinTransaction.MWEB_PEGOUT_TX_FLAG = 0x08;
|
46
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiTGl0ZWNvaW5UcmFuc2FjdGlvbi5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3NyYy9iaXRnby9saXRlY29pbi9MaXRlY29pblRyYW5zYWN0aW9uLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQUFBLCtEQUEyRTtBQUUzRSx3REFBcUQ7QUFDckQsNkNBQStEO0FBSS9EOzs7R0FHRztBQUNILE1BQWEsbUJBQThELFNBQVEsaUNBQXdCO0lBR3pHLFlBQVksT0FBZ0IsRUFBRSxFQUF5QyxFQUFFLFVBQWdDO1FBQ3ZHLEtBQUssQ0FBQyxPQUFPLEVBQUUsRUFBRSxFQUFFLFVBQVUsQ0FBQyxDQUFDO1FBRS9CLElBQUksQ0FBQyxxQkFBVSxDQUFDLE9BQU8sQ0FBQyxFQUFFO1lBQ3hCL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lNBQ1RJT05fTUFSS0VSICYmXG4gICAgICBmbGFnID09PSBMaXRlY29pblRyYW5zYWN0aW9uLk1XRUJfUEVHT1VUX1RYX0ZMQUdcbiAgICApIHtcbiAgICAgIC8vIExpdGVjb2luIGhhcyBhbiBNV0VCIGFkdmFuY2VkIHRyYW5zYWN0aW9uIG1hcmtlci4gU2xpY2Ugb3V0IHRoZSBtYXJrZXIgYW5kIDV0aCB0byBsYXN0IGJ5dGUgIGFuZCByZWFkIGxpa2UgYSBub3JtYWwgdHJhbnNhY3Rpb25cbiAgICAgIGNvbnN0IGJ1ZmZlcldyaXRlciA9IG5ldyBCdWZmZXJXcml0ZXIoQnVmZmVyLmFsbG9jVW5zYWZlKGJ1ZmZlci5sZW5ndGggLSAzKSk7XG4gICAgICBidWZmZXJXcml0ZXIud3JpdGVVSW50MzIodHhWZXJzaW9uKTtcbiAgICAgIGJ1ZmZlcldyaXRlci53cml0ZVNsaWNlKGJ1ZmZlci5zbGljZSg2LCBidWZmZXIubGVuZ3RoIC0gNSkpO1xuICAgICAgYnVmZmVyV3JpdGVyLndyaXRlU2xpY2UoYnVmZmVyLnNsaWNlKGJ1ZmZlci5sZW5ndGggLSA0LCBidWZmZXIubGVuZ3RoKSk7XG4gICAgICByZXR1cm4gc3VwZXIuZnJvbUJ1ZmZlcihidWZmZXJXcml0ZXIuYnVmZmVyLCBub1N0cmljdCwgYW1vdW50VHlwZSwgbmV0d29yayk7XG4gICAgfVxuICAgIHJldHVybiBzdXBlci5mcm9tQnVmZmVyKGJ1ZmZlciwgbm9TdHJpY3QsIGFtb3VudFR5cGUsIG5ldHdvcmspO1xuICB9XG59XG4iXX0=
|
@@ -1,10 +0,0 @@
|
|
1
|
-
import * as bitcoinjs from 'bitcoinjs-lib';
|
2
|
-
import { UtxoTransactionBuilder } from '../UtxoTransactionBuilder';
|
3
|
-
import { Network } from '../../networks';
|
4
|
-
import { UtxoTransaction } from '../UtxoTransaction';
|
5
|
-
import { LitecoinTransaction } from './LitecoinTransaction';
|
6
|
-
export declare class LitecoinTransactionBuilder<TNumber extends number | bigint = number> extends UtxoTransactionBuilder<TNumber, LitecoinTransaction<TNumber>> {
|
7
|
-
protected static newTransactionBuilder<TNumber extends number | bigint>(network: Network, tx: UtxoTransaction<TNumber>): LitecoinTransactionBuilder<TNumber>;
|
8
|
-
protected createInitialTransaction(network: Network, tx?: bitcoinjs.Transaction<TNumber>): LitecoinTransaction<TNumber>;
|
9
|
-
}
|
10
|
-
//# sourceMappingURL=LitecoinTransactionBuilder.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"LitecoinTransactionBuilder.d.ts","sourceRoot":"","sources":["../../../../src/bitgo/litecoin/LitecoinTransactionBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,eAAe,CAAC;AAE3C,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,qBAAa,0BAA0B,CAAC,OAAO,SAAS,MAAM,GAAG,MAAM,GAAG,MAAM,CAAE,SAAQ,sBAAsB,CAC9G,OAAO,EACP,mBAAmB,CAAC,OAAO,CAAC,CAC7B;IACC,SAAS,CAAC,MAAM,CAAC,qBAAqB,CAAC,OAAO,SAAS,MAAM,GAAG,MAAM,EACpE,OAAO,EAAE,OAAO,EAChB,EAAE,EAAE,eAAe,CAAC,OAAO,CAAC,GAC3B,0BAA0B,CAAC,OAAO,CAAC;IAItC,SAAS,CAAC,wBAAwB,CAChC,OAAO,EAAE,OAAO,EAChB,EAAE,CAAC,EAAE,SAAS,CAAC,WAAW,CAAC,OAAO,CAAC,GAClC,mBAAmB,CAAC,OAAO,CAAC;CAGhC"}
|
@@ -1,15 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.LitecoinTransactionBuilder = void 0;
|
4
|
-
const UtxoTransactionBuilder_1 = require("../UtxoTransactionBuilder");
|
5
|
-
const LitecoinTransaction_1 = require("./LitecoinTransaction");
|
6
|
-
class LitecoinTransactionBuilder extends UtxoTransactionBuilder_1.UtxoTransactionBuilder {
|
7
|
-
static newTransactionBuilder(network, tx) {
|
8
|
-
return new LitecoinTransactionBuilder(network, tx);
|
9
|
-
}
|
10
|
-
createInitialTransaction(network, tx) {
|
11
|
-
return new LitecoinTransaction_1.LitecoinTransaction(network, tx);
|
12
|
-
}
|
13
|
-
}
|
14
|
-
exports.LitecoinTransactionBuilder = LitecoinTransactionBuilder;
|
15
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiTGl0ZWNvaW5UcmFuc2FjdGlvbkJ1aWxkZXIuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9zcmMvYml0Z28vbGl0ZWNvaW4vTGl0ZWNvaW5UcmFuc2FjdGlvbkJ1aWxkZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBRUEsc0VBQW1FO0FBR25FLCtEQUE0RDtBQUU1RCxNQUFhLDBCQUFxRSxTQUFRLCtDQUd6RjtJQUNXLE1BQU0sQ0FBQyxxQkFBcUIsQ0FDcEMsT0FBZ0IsRUFDaEIsRUFBNEI7UUFFNUIsT0FBTyxJQUFJLDBCQUEwQixDQUFVLE9BQU8sRUFBRSxFQUFFLENBQUMsQ0FBQztJQUM5RCxDQUFDO0lBRVMsd0JBQXdCLENBQ2hDLE9BQWdCLEVBQ2hCLEVBQW1DO1FBRW5DLE9BQU8sSUFBSSx5Q0FBbUIsQ0FBVSxPQUFPLEVBQUUsRUFBa0MsQ0FBQyxDQUFDO0lBQ3ZGLENBQUM7Q0FDRjtBQWpCRCxnRUFpQkMiLCJzb3Vy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aW9uPFROdW1iZXI+XG4gICk6IExpdGVjb2luVHJhbnNhY3Rpb248VE51bWJlcj4ge1xuICAgIHJldHVybiBuZXcgTGl0ZWNvaW5UcmFuc2FjdGlvbjxUTnVtYmVyPihuZXR3b3JrLCB0eCBhcyBMaXRlY29pblRyYW5zYWN0aW9uPFROdW1iZXI+KTtcbiAgfVxufVxuIl19
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/bitgo/litecoin/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,8BAA8B,CAAC"}
|
@@ -1,71 +0,0 @@
|
|
1
|
-
import { ScriptType, ScriptType2Of3 } from '../bitgo/outputScripts';
|
2
|
-
import { KeyName, RootWalletKeys, Unspent, UtxoPsbt, UtxoTransaction, WalletUnspent } from '../bitgo';
|
3
|
-
import { Network } from '../networks';
|
4
|
-
/**
|
5
|
-
* input script type and value.
|
6
|
-
* use p2trMusig2 for p2trMusig2 script path.
|
7
|
-
* use taprootKeyPathSpend for p2trMusig2 key path.
|
8
|
-
*/
|
9
|
-
export declare type InputScriptType = ScriptType | 'taprootKeyPathSpend';
|
10
|
-
export declare type OutputScriptType = ScriptType2Of3;
|
11
|
-
/**
|
12
|
-
* input script type and value
|
13
|
-
*/
|
14
|
-
export interface Input {
|
15
|
-
scriptType: InputScriptType;
|
16
|
-
value: bigint;
|
17
|
-
}
|
18
|
-
/**
|
19
|
-
* should set either address or scriptType, never both.
|
20
|
-
* set isInternalAddress=true for internal output address
|
21
|
-
*/
|
22
|
-
export interface Output {
|
23
|
-
address?: string;
|
24
|
-
scriptType?: OutputScriptType;
|
25
|
-
value: bigint;
|
26
|
-
isInternalAddress?: boolean;
|
27
|
-
}
|
28
|
-
/**
|
29
|
-
* array of supported input script types.
|
30
|
-
* use p2trMusig2 for p2trMusig2 script path.
|
31
|
-
* use taprootKeyPathSpend for p2trMusig2 key path.
|
32
|
-
*/
|
33
|
-
export declare const inputScriptTypes: readonly ["p2sh", "p2shP2wsh", "p2wsh", "p2tr", "p2trMusig2", "taprootKeyPathSpend", "p2shP2pk"];
|
34
|
-
/**
|
35
|
-
* array of supported output script types.
|
36
|
-
*/
|
37
|
-
export declare const outputScriptTypes: readonly ["p2sh", "p2shP2wsh", "p2wsh", "p2tr", "p2trMusig2"];
|
38
|
-
/**
|
39
|
-
* create unspent object from input script type, index, network and root wallet key.
|
40
|
-
*/
|
41
|
-
export declare function toUnspent(input: Input, index: number, network: Network, rootWalletKeys: RootWalletKeys): Unspent<bigint>;
|
42
|
-
/**
|
43
|
-
* returns signer and cosigner names for InputScriptType.
|
44
|
-
* user and undefined as signer and cosigner respectively for p2shP2pk.
|
45
|
-
* user and backup as signer and cosigner respectively for p2trMusig2.
|
46
|
-
* user and bitgo as signer and cosigner respectively for other input script types.
|
47
|
-
*/
|
48
|
-
export declare function getSigners(inputType: InputScriptType): {
|
49
|
-
signerName: KeyName;
|
50
|
-
cosignerName?: KeyName;
|
51
|
-
};
|
52
|
-
/**
|
53
|
-
* signs with first or second signature for single input.
|
54
|
-
* p2shP2pk is signed only with first sign.
|
55
|
-
*/
|
56
|
-
export declare function signPsbtInput(psbt: UtxoPsbt, input: Input, inputIndex: number, rootWalletKeys: RootWalletKeys, sign: 'halfsigned' | 'fullsigned'): void;
|
57
|
-
/**
|
58
|
-
* signs with first or second signature for all inputs.
|
59
|
-
* p2shP2pk is signed only with first sign.
|
60
|
-
*/
|
61
|
-
export declare function signAllPsbtInputs(psbt: UtxoPsbt, inputs: Input[], rootWalletKeys: RootWalletKeys, sign: 'halfsigned' | 'fullsigned'): void;
|
62
|
-
/**
|
63
|
-
* construct psbt for given inputs, outputs, network and root wallet keys.
|
64
|
-
*/
|
65
|
-
export declare function constructPsbt(inputs: Input[], outputs: Output[], network: Network, rootWalletKeys: RootWalletKeys, sign: 'unsigned' | 'halfsigned' | 'fullsigned'): UtxoPsbt;
|
66
|
-
/**
|
67
|
-
* Verifies signatures of fully signed tx (with taproot key path support).
|
68
|
-
* NOTE: taproot key path tx can only be built and signed with PSBT.
|
69
|
-
*/
|
70
|
-
export declare function verifyFullySignedSignatures(tx: UtxoTransaction<bigint>, unspents: WalletUnspent<bigint>[], walletKeys: RootWalletKeys, signer: KeyName, cosigner: KeyName): boolean;
|
71
|
-
//# sourceMappingURL=psbt.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"psbt.d.ts","sourceRoot":"","sources":["../../../src/testutil/psbt.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,UAAU,EACV,cAAc,EAGf,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAQL,OAAO,EAGP,cAAc,EAEd,OAAO,EACP,QAAQ,EACR,eAAe,EAEf,aAAa,EACd,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAItC;;;;GAIG;AACH,oBAAY,eAAe,GAAG,UAAU,GAAG,qBAAqB,CAAC;AACjE,oBAAY,gBAAgB,GAAG,cAAc,CAAC;AAE9C;;GAEG;AACH,MAAM,WAAW,KAAK;IACpB,UAAU,EAAE,eAAe,CAAC;IAC5B,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;GAGG;AACH,MAAM,WAAW,MAAM;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,gBAAgB,CAAC;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,kGAA2E,CAAC;AAEzG;;GAEG;AACH,eAAO,MAAM,iBAAiB,+DAAkB,CAAC;AAEjD;;GAEG;AACH,wBAAgB,SAAS,CACvB,KAAK,EAAE,KAAK,EACZ,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,OAAO,EAChB,cAAc,EAAE,cAAc,GAC7B,OAAO,CAAC,MAAM,CAAC,CAYjB;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,SAAS,EAAE,eAAe,GAAG;IAAE,UAAU,EAAE,OAAO,CAAC;IAAC,YAAY,CAAC,EAAE,OAAO,CAAA;CAAE,CAKtG;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAC3B,IAAI,EAAE,QAAQ,EACd,KAAK,EAAE,KAAK,EACZ,UAAU,EAAE,MAAM,EAClB,cAAc,EAAE,cAAc,EAC9B,IAAI,EAAE,YAAY,GAAG,YAAY,GAChC,IAAI,CAYN;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,QAAQ,EACd,MAAM,EAAE,KAAK,EAAE,EACf,cAAc,EAAE,cAAc,EAC9B,IAAI,EAAE,YAAY,GAAG,YAAY,GAChC,IAAI,CAIN;AAED;;GAEG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,KAAK,EAAE,EACf,OAAO,EAAE,MAAM,EAAE,EACjB,OAAO,EAAE,OAAO,EAChB,cAAc,EAAE,cAAc,EAC9B,IAAI,EAAE,UAAU,GAAG,YAAY,GAAG,YAAY,GAC7C,QAAQ,CAoDV;AAED;;;GAGG;AACH,wBAAgB,2BAA2B,CACzC,EAAE,EAAE,eAAe,CAAC,MAAM,CAAC,EAC3B,QAAQ,EAAE,aAAa,CAAC,MAAM,CAAC,EAAE,EACjC,UAAU,EAAE,cAAc,EAC1B,MAAM,EAAE,OAAO,EACf,QAAQ,EAAE,OAAO,GAChB,OAAO,CAiBT"}
|
@@ -1,147 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.verifyFullySignedSignatures = exports.constructPsbt = exports.signAllPsbtInputs = exports.signPsbtInput = exports.getSigners = exports.toUnspent = exports.outputScriptTypes = exports.inputScriptTypes = void 0;
|
4
|
-
const assert = require("assert");
|
5
|
-
const outputScripts_1 = require("../bitgo/outputScripts");
|
6
|
-
const bitgo_1 = require("../bitgo");
|
7
|
-
const mock_1 = require("./mock");
|
8
|
-
const address_1 = require("../address");
|
9
|
-
/**
|
10
|
-
* array of supported input script types.
|
11
|
-
* use p2trMusig2 for p2trMusig2 script path.
|
12
|
-
* use taprootKeyPathSpend for p2trMusig2 key path.
|
13
|
-
*/
|
14
|
-
exports.inputScriptTypes = [...outputScripts_1.scriptTypes2Of3, 'taprootKeyPathSpend', outputScripts_1.scriptTypeP2shP2pk];
|
15
|
-
/**
|
16
|
-
* array of supported output script types.
|
17
|
-
*/
|
18
|
-
exports.outputScriptTypes = outputScripts_1.scriptTypes2Of3;
|
19
|
-
/**
|
20
|
-
* create unspent object from input script type, index, network and root wallet key.
|
21
|
-
*/
|
22
|
-
function toUnspent(input, index, network, rootWalletKeys) {
|
23
|
-
if (input.scriptType === 'p2shP2pk') {
|
24
|
-
return mock_1.mockReplayProtectionUnspent(network, input.value, { key: rootWalletKeys['user'], vout: index });
|
25
|
-
}
|
26
|
-
else {
|
27
|
-
const chain = bitgo_1.getInternalChainCode(input.scriptType === 'taprootKeyPathSpend' ? 'p2trMusig2' : input.scriptType);
|
28
|
-
return mock_1.mockWalletUnspent(network, input.value, {
|
29
|
-
chain,
|
30
|
-
vout: index,
|
31
|
-
keys: rootWalletKeys,
|
32
|
-
index,
|
33
|
-
});
|
34
|
-
}
|
35
|
-
}
|
36
|
-
exports.toUnspent = toUnspent;
|
37
|
-
/**
|
38
|
-
* returns signer and cosigner names for InputScriptType.
|
39
|
-
* user and undefined as signer and cosigner respectively for p2shP2pk.
|
40
|
-
* user and backup as signer and cosigner respectively for p2trMusig2.
|
41
|
-
* user and bitgo as signer and cosigner respectively for other input script types.
|
42
|
-
*/
|
43
|
-
function getSigners(inputType) {
|
44
|
-
return {
|
45
|
-
signerName: 'user',
|
46
|
-
cosignerName: inputType === 'p2shP2pk' ? undefined : inputType === 'p2trMusig2' ? 'backup' : 'bitgo',
|
47
|
-
};
|
48
|
-
}
|
49
|
-
exports.getSigners = getSigners;
|
50
|
-
/**
|
51
|
-
* signs with first or second signature for single input.
|
52
|
-
* p2shP2pk is signed only with first sign.
|
53
|
-
*/
|
54
|
-
function signPsbtInput(psbt, input, inputIndex, rootWalletKeys, sign) {
|
55
|
-
const { signerName, cosignerName } = getSigners(input.scriptType);
|
56
|
-
if (sign === 'halfsigned') {
|
57
|
-
if (input.scriptType === 'p2shP2pk') {
|
58
|
-
psbt.signInput(inputIndex, rootWalletKeys[signerName]);
|
59
|
-
}
|
60
|
-
else {
|
61
|
-
psbt.signInputHD(inputIndex, rootWalletKeys[signerName]);
|
62
|
-
}
|
63
|
-
}
|
64
|
-
if (sign === 'fullsigned' && cosignerName) {
|
65
|
-
psbt.signInputHD(inputIndex, rootWalletKeys[cosignerName]);
|
66
|
-
}
|
67
|
-
}
|
68
|
-
exports.signPsbtInput = signPsbtInput;
|
69
|
-
/**
|
70
|
-
* signs with first or second signature for all inputs.
|
71
|
-
* p2shP2pk is signed only with first sign.
|
72
|
-
*/
|
73
|
-
function signAllPsbtInputs(psbt, inputs, rootWalletKeys, sign) {
|
74
|
-
inputs.forEach((input, index) => {
|
75
|
-
signPsbtInput(psbt, input, index, rootWalletKeys, sign);
|
76
|
-
});
|
77
|
-
}
|
78
|
-
exports.signAllPsbtInputs = signAllPsbtInputs;
|
79
|
-
/**
|
80
|
-
* construct psbt for given inputs, outputs, network and root wallet keys.
|
81
|
-
*/
|
82
|
-
function constructPsbt(inputs, outputs, network, rootWalletKeys, sign) {
|
83
|
-
const totalInputAmount = inputs.reduce((sum, input) => sum + input.value, BigInt(0));
|
84
|
-
const outputInputAmount = outputs.reduce((sum, output) => sum + output.value, BigInt(0));
|
85
|
-
assert(totalInputAmount >= outputInputAmount, 'total output can not exceed total input');
|
86
|
-
assert(!outputs.some((o) => (o.scriptType && o.address) || (!o.scriptType && !o.address)), 'only either output script type or address should be provided');
|
87
|
-
const psbt = bitgo_1.createPsbtForNetwork({ network });
|
88
|
-
const unspents = inputs.map((input, i) => toUnspent(input, i, network, rootWalletKeys));
|
89
|
-
unspents.forEach((u, i) => {
|
90
|
-
const { signerName, cosignerName } = getSigners(inputs[i].scriptType);
|
91
|
-
if (bitgo_1.isWalletUnspent(u) && cosignerName) {
|
92
|
-
bitgo_1.addWalletUnspentToPsbt(psbt, u, rootWalletKeys, signerName, cosignerName);
|
93
|
-
}
|
94
|
-
else {
|
95
|
-
const { redeemScript } = outputScripts_1.createOutputScriptP2shP2pk(rootWalletKeys[signerName].publicKey);
|
96
|
-
assert(redeemScript);
|
97
|
-
bitgo_1.addReplayProtectionUnspentToPsbt(psbt, u, redeemScript);
|
98
|
-
}
|
99
|
-
});
|
100
|
-
outputs.forEach((output, i) => {
|
101
|
-
if (output.scriptType) {
|
102
|
-
bitgo_1.addWalletOutputToPsbt(psbt, rootWalletKeys, output.isInternalAddress ? bitgo_1.getInternalChainCode(output.scriptType) : bitgo_1.getExternalChainCode(output.scriptType), i, output.value);
|
103
|
-
}
|
104
|
-
else if (output.address) {
|
105
|
-
const { address, value } = output;
|
106
|
-
psbt.addOutput({ script: address_1.toOutputScript(address, network), value });
|
107
|
-
}
|
108
|
-
});
|
109
|
-
if (sign === 'unsigned') {
|
110
|
-
return psbt;
|
111
|
-
}
|
112
|
-
psbt.setAllInputsMusig2NonceHD(rootWalletKeys['user']);
|
113
|
-
psbt.setAllInputsMusig2NonceHD(rootWalletKeys['bitgo']);
|
114
|
-
signAllPsbtInputs(psbt, inputs, rootWalletKeys, 'halfsigned');
|
115
|
-
if (sign === 'fullsigned') {
|
116
|
-
signAllPsbtInputs(psbt, inputs, rootWalletKeys, sign);
|
117
|
-
}
|
118
|
-
return psbt;
|
119
|
-
}
|
120
|
-
exports.constructPsbt = constructPsbt;
|
121
|
-
/**
|
122
|
-
* Verifies signatures of fully signed tx (with taproot key path support).
|
123
|
-
* NOTE: taproot key path tx can only be built and signed with PSBT.
|
124
|
-
*/
|
125
|
-
function verifyFullySignedSignatures(tx, unspents, walletKeys, signer, cosigner) {
|
126
|
-
const prevOutputs = unspents.map((u) => bitgo_1.toOutput(u, tx.network));
|
127
|
-
return unspents.every((u, index) => {
|
128
|
-
if (bitgo_1.parseSignatureScript2Of3(tx.ins[index]).scriptType === 'taprootKeyPathSpend') {
|
129
|
-
const result = bitgo_1.getSignatureVerifications(tx, index, u.value, undefined, prevOutputs);
|
130
|
-
return result.length === 1 && result[0].signature;
|
131
|
-
}
|
132
|
-
else {
|
133
|
-
const result = bitgo_1.verifySignatureWithUnspent(tx, index, unspents, walletKeys);
|
134
|
-
if ((signer === 'user' && cosigner === 'bitgo') || (signer === 'bitgo' && cosigner === 'user')) {
|
135
|
-
return result[0] && !result[1] && result[2];
|
136
|
-
}
|
137
|
-
else if ((signer === 'user' && cosigner === 'backup') || (signer === 'backup' && cosigner === 'user')) {
|
138
|
-
return result[0] && result[1] && !result[2];
|
139
|
-
}
|
140
|
-
else {
|
141
|
-
return !result[0] && result[1] && result[2];
|
142
|
-
}
|
143
|
-
}
|
144
|
-
});
|
145
|
-
}
|
146
|
-
exports.verifyFullySignedSignatures = verifyFullySignedSignatures;
|
147
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHNidC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy90ZXN0dXRpbC9wc2J0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQUFBLGlDQUFpQztBQUVqQywwREFNZ0M7QUFDaEMsb0NBa0JrQjtBQUVsQixpQ0FBd0U7QUFDeEUsd0NBQTRDO0FBNkI1Qzs7OztHQUlHO0FBQ1UsUUFBQSxnQkFBZ0IsR0FBRyxDQUFDLEdBQUcsK0JBQWUsRUFBRSxxQkFBcUIsRUFBRSxrQ0FBa0IsQ0FBVSxDQUFDO0FBRXpHOztHQUVHO0FBQ1UsUUFBQSxpQkFBaUIsR0FBRywrQkFBZSxDQUFDO0FBRWpEOztHQUVHO0FBQ0gsU0F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AnYml0Z28nICYmIGNvc2lnbmVyID09PSAndXNlcicpKSB7XG4gICAgICAgIHJldHVybiByZXN1bHRbMF0gJiYgIXJlc3VsdFsxXSAmJiByZXN1bHRbMl07XG4gICAgICB9IGVsc2UgaWYgKChzaWduZXIgPT09ICd1c2VyJyAmJiBjb3NpZ25lciA9PT0gJ2JhY2t1cCcpIHx8IChzaWduZXIgPT09ICdiYWNrdXAnICYmIGNvc2lnbmVyID09PSAndXNlcicpKSB7XG4gICAgICAgIHJldHVybiByZXN1bHRbMF0gJiYgcmVzdWx0WzFdICYmICFyZXN1bHRbMl07XG4gICAgICB9IGVsc2Uge1xuICAgICAgICByZXR1cm4gIXJlc3VsdFswXSAmJiByZXN1bHRbMV0gJiYgcmVzdWx0WzJdO1xuICAgICAgfVxuICAgIH1cbiAgfSk7XG59XG4iXX0=
|
@@ -1,61 +0,0 @@
|
|
1
|
-
import { ScriptType, ScriptType2Of3 } from '../bitgo/outputScripts';
|
2
|
-
import { KeyName, RootWalletKeys, Unspent, UtxoTransactionBuilder } from '../bitgo';
|
3
|
-
import { Network } from '../networks';
|
4
|
-
/**
|
5
|
-
* input script type and value.
|
6
|
-
*/
|
7
|
-
export declare type TxnInputScriptType = Exclude<ScriptType, 'p2trMusig2'>;
|
8
|
-
export declare type TxnOutputScriptType = Exclude<ScriptType2Of3, 'p2trMusig2'>;
|
9
|
-
/**
|
10
|
-
* output script type and value
|
11
|
-
*/
|
12
|
-
export interface TxnInput<TNumber extends number | bigint> {
|
13
|
-
scriptType: TxnInputScriptType;
|
14
|
-
value: TNumber;
|
15
|
-
}
|
16
|
-
/**
|
17
|
-
* should set either address or scriptType, never both.
|
18
|
-
* set isInternalAddress=true for internal output address
|
19
|
-
*/
|
20
|
-
export interface TxnOutput<TNumber extends number | bigint> {
|
21
|
-
address?: string;
|
22
|
-
scriptType?: TxnOutputScriptType;
|
23
|
-
value: TNumber;
|
24
|
-
isInternalAddress?: boolean;
|
25
|
-
}
|
26
|
-
/**
|
27
|
-
* array of supported input script types.
|
28
|
-
*/
|
29
|
-
export declare const txnInputScriptTypes: readonly ["p2sh", "p2shP2wsh", "p2wsh", "p2tr", "p2shP2pk"];
|
30
|
-
/**
|
31
|
-
* array of supported output script types.
|
32
|
-
*/
|
33
|
-
export declare const txnOutputScriptTypes: readonly ["p2sh", "p2shP2wsh", "p2wsh", "p2tr"];
|
34
|
-
/**
|
35
|
-
* create unspent object from input script type, index, network and root wallet key.
|
36
|
-
*/
|
37
|
-
export declare function toTxnUnspent<TNumber extends number | bigint>(input: TxnInput<TNumber>, index: number, network: Network, rootWalletKeys: RootWalletKeys): Unspent<TNumber>;
|
38
|
-
/**
|
39
|
-
* returns signer and cosigner names for TxnInputScriptType.
|
40
|
-
* user and undefined as signer and cosigner respectively for p2shP2pk.
|
41
|
-
* user and bitgo as signer and cosigner respectively for other input script types.
|
42
|
-
*/
|
43
|
-
export declare function getTxnSigners(inputType: TxnInputScriptType): {
|
44
|
-
signerName: KeyName;
|
45
|
-
cosignerName?: KeyName;
|
46
|
-
};
|
47
|
-
/**
|
48
|
-
* signs with first or second signature for single input.
|
49
|
-
* p2shP2pk is signed only with first sign.
|
50
|
-
*/
|
51
|
-
export declare function signTxnInput<TNumber extends number | bigint>(txb: UtxoTransactionBuilder<TNumber>, input: TxnInput<TNumber>, inputIndex: number, rootWalletKeys: RootWalletKeys, sign: 'halfsigned' | 'fullsigned'): void;
|
52
|
-
/**
|
53
|
-
* signs with first or second signature for all inputs.
|
54
|
-
* p2shP2pk is signed only with first sign.
|
55
|
-
*/
|
56
|
-
export declare function signAllTxnInputs<TNumber extends number | bigint>(txb: UtxoTransactionBuilder<TNumber>, inputs: TxnInput<TNumber>[], rootWalletKeys: RootWalletKeys, sign: 'halfsigned' | 'fullsigned'): void;
|
57
|
-
/**
|
58
|
-
* construct transaction for given inputs, outputs, network and root wallet keys.
|
59
|
-
*/
|
60
|
-
export declare function constructTxnBuilder<TNumber extends number | bigint>(inputs: TxnInput<TNumber>[], outputs: TxnOutput<TNumber>[], network: Network, rootWalletKeys: RootWalletKeys, sign: 'unsigned' | 'halfsigned' | 'fullsigned'): UtxoTransactionBuilder<TNumber>;
|
61
|
-
//# sourceMappingURL=transaction.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"transaction.d.ts","sourceRoot":"","sources":["../../../src/testutil/transaction.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,cAAc,EAAsB,MAAM,wBAAwB,CAAC;AACxF,OAAO,EAGL,OAAO,EAEP,cAAc,EACd,OAAO,EACP,sBAAsB,EAOvB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAGtC;;GAEG;AACH,oBAAY,kBAAkB,GAAG,OAAO,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC;AACnE,oBAAY,mBAAmB,GAAG,OAAO,CAAC,cAAc,EAAE,YAAY,CAAC,CAAC;AAExE;;GAEG;AACH,MAAM,WAAW,QAAQ,CAAC,OAAO,SAAS,MAAM,GAAG,MAAM;IACvD,UAAU,EAAE,kBAAkB,CAAC;IAC/B,KAAK,EAAE,OAAO,CAAC;CAChB;AAED;;;GAGG;AACH,MAAM,WAAW,SAAS,CAAC,OAAO,SAAS,MAAM,GAAG,MAAM;IACxD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,mBAAmB,CAAC;IACjC,KAAK,EAAE,OAAO,CAAC;IACf,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED;;GAEG;AACH,eAAO,MAAM,mBAAmB,6DAAsE,CAAC;AAEvG;;GAEG;AACH,eAAO,MAAM,oBAAoB,iDAAkD,CAAC;AAEpF;;GAEG;AACH,wBAAgB,YAAY,CAAC,OAAO,SAAS,MAAM,GAAG,MAAM,EAC1D,KAAK,EAAE,QAAQ,CAAC,OAAO,CAAC,EACxB,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,OAAO,EAChB,cAAc,EAAE,cAAc,GAC7B,OAAO,CAAC,OAAO,CAAC,CAWlB;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,SAAS,EAAE,kBAAkB,GAAG;IAAE,UAAU,EAAE,OAAO,CAAC;IAAC,YAAY,CAAC,EAAE,OAAO,CAAA;CAAE,CAK5G;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,OAAO,SAAS,MAAM,GAAG,MAAM,EAC1D,GAAG,EAAE,sBAAsB,CAAC,OAAO,CAAC,EACpC,KAAK,EAAE,QAAQ,CAAC,OAAO,CAAC,EACxB,UAAU,EAAE,MAAM,EAClB,cAAc,EAAE,cAAc,EAC9B,IAAI,EAAE,YAAY,GAAG,YAAY,GAChC,IAAI,CAuBN;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,SAAS,MAAM,GAAG,MAAM,EAC9D,GAAG,EAAE,sBAAsB,CAAC,OAAO,CAAC,EACpC,MAAM,EAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,EAC3B,cAAc,EAAE,cAAc,EAC9B,IAAI,EAAE,YAAY,GAAG,YAAY,GAChC,IAAI,CAIN;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,SAAS,MAAM,GAAG,MAAM,EACjE,MAAM,EAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,EAC3B,OAAO,EAAE,SAAS,CAAC,OAAO,CAAC,EAAE,EAC7B,OAAO,EAAE,OAAO,EAChB,cAAc,EAAE,cAAc,EAC9B,IAAI,EAAE,UAAU,GAAG,YAAY,GAAG,YAAY,GAC7C,sBAAsB,CAAC,OAAO,CAAC,CA2CjC"}
|
@@ -1,107 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.constructTxnBuilder = exports.signAllTxnInputs = exports.signTxnInput = exports.getTxnSigners = exports.toTxnUnspent = exports.txnOutputScriptTypes = exports.txnInputScriptTypes = void 0;
|
4
|
-
const assert = require("assert");
|
5
|
-
const outputScripts_1 = require("../bitgo/outputScripts");
|
6
|
-
const bitgo_1 = require("../bitgo");
|
7
|
-
const mock_1 = require("./mock");
|
8
|
-
/**
|
9
|
-
* array of supported input script types.
|
10
|
-
*/
|
11
|
-
exports.txnInputScriptTypes = ['p2sh', 'p2shP2wsh', 'p2wsh', 'p2tr', outputScripts_1.scriptTypeP2shP2pk];
|
12
|
-
/**
|
13
|
-
* array of supported output script types.
|
14
|
-
*/
|
15
|
-
exports.txnOutputScriptTypes = ['p2sh', 'p2shP2wsh', 'p2wsh', 'p2tr'];
|
16
|
-
/**
|
17
|
-
* create unspent object from input script type, index, network and root wallet key.
|
18
|
-
*/
|
19
|
-
function toTxnUnspent(input, index, network, rootWalletKeys) {
|
20
|
-
if (input.scriptType === 'p2shP2pk') {
|
21
|
-
return mock_1.mockReplayProtectionUnspent(network, input.value, { key: rootWalletKeys['user'], vout: index });
|
22
|
-
}
|
23
|
-
else {
|
24
|
-
return mock_1.mockWalletUnspent(network, input.value, {
|
25
|
-
chain: bitgo_1.getInternalChainCode(input.scriptType),
|
26
|
-
vout: index,
|
27
|
-
keys: rootWalletKeys,
|
28
|
-
index,
|
29
|
-
});
|
30
|
-
}
|
31
|
-
}
|
32
|
-
exports.toTxnUnspent = toTxnUnspent;
|
33
|
-
/**
|
34
|
-
* returns signer and cosigner names for TxnInputScriptType.
|
35
|
-
* user and undefined as signer and cosigner respectively for p2shP2pk.
|
36
|
-
* user and bitgo as signer and cosigner respectively for other input script types.
|
37
|
-
*/
|
38
|
-
function getTxnSigners(inputType) {
|
39
|
-
return {
|
40
|
-
signerName: 'user',
|
41
|
-
cosignerName: inputType === 'p2shP2pk' ? undefined : 'bitgo',
|
42
|
-
};
|
43
|
-
}
|
44
|
-
exports.getTxnSigners = getTxnSigners;
|
45
|
-
/**
|
46
|
-
* signs with first or second signature for single input.
|
47
|
-
* p2shP2pk is signed only with first sign.
|
48
|
-
*/
|
49
|
-
function signTxnInput(txb, input, inputIndex, rootWalletKeys, sign) {
|
50
|
-
const { signerName, cosignerName } = getTxnSigners(input.scriptType);
|
51
|
-
const unspent = toTxnUnspent(input, inputIndex, txb.network, rootWalletKeys);
|
52
|
-
if (sign === 'halfsigned') {
|
53
|
-
if (input.scriptType === 'p2shP2pk') {
|
54
|
-
bitgo_1.signInputP2shP2pk(txb, inputIndex, rootWalletKeys[signerName]);
|
55
|
-
}
|
56
|
-
else if (bitgo_1.isWalletUnspent(unspent) && cosignerName) {
|
57
|
-
bitgo_1.signInputWithUnspent(txb, inputIndex, unspent, bitgo_1.WalletUnspentSigner.from(rootWalletKeys, rootWalletKeys[signerName], rootWalletKeys[cosignerName]));
|
58
|
-
}
|
59
|
-
}
|
60
|
-
if (bitgo_1.isWalletUnspent(unspent) && sign === 'fullsigned' && cosignerName) {
|
61
|
-
bitgo_1.signInputWithUnspent(txb, inputIndex, unspent, bitgo_1.WalletUnspentSigner.from(rootWalletKeys, rootWalletKeys[cosignerName], rootWalletKeys[signerName]));
|
62
|
-
}
|
63
|
-
}
|
64
|
-
exports.signTxnInput = signTxnInput;
|
65
|
-
/**
|
66
|
-
* signs with first or second signature for all inputs.
|
67
|
-
* p2shP2pk is signed only with first sign.
|
68
|
-
*/
|
69
|
-
function signAllTxnInputs(txb, inputs, rootWalletKeys, sign) {
|
70
|
-
inputs.forEach((input, index) => {
|
71
|
-
signTxnInput(txb, input, index, rootWalletKeys, sign);
|
72
|
-
});
|
73
|
-
}
|
74
|
-
exports.signAllTxnInputs = signAllTxnInputs;
|
75
|
-
/**
|
76
|
-
* construct transaction for given inputs, outputs, network and root wallet keys.
|
77
|
-
*/
|
78
|
-
function constructTxnBuilder(inputs, outputs, network, rootWalletKeys, sign) {
|
79
|
-
const totalInputAmount = inputs.reduce((sum, input) => sum + BigInt(input.value), BigInt(0));
|
80
|
-
const outputInputAmount = outputs.reduce((sum, output) => sum + BigInt(output.value), BigInt(0));
|
81
|
-
assert(totalInputAmount >= outputInputAmount, 'total output can not exceed total input');
|
82
|
-
assert(!outputs.some((o) => (o.scriptType && o.address) || (!o.scriptType && !o.address)), 'only either output script type or address should be provided');
|
83
|
-
const txb = bitgo_1.createTransactionBuilderForNetwork(network);
|
84
|
-
const unspents = inputs.map((input, i) => toTxnUnspent(input, i, network, rootWalletKeys));
|
85
|
-
unspents.forEach((u, i) => {
|
86
|
-
bitgo_1.addToTransactionBuilder(txb, u);
|
87
|
-
});
|
88
|
-
outputs.forEach((output, i) => {
|
89
|
-
const address = output.scriptType
|
90
|
-
? bitgo_1.getWalletAddress(rootWalletKeys, output.isInternalAddress ? bitgo_1.getInternalChainCode(output.scriptType) : bitgo_1.getExternalChainCode(output.scriptType), i, network)
|
91
|
-
: output.address;
|
92
|
-
if (!address) {
|
93
|
-
throw new Error('address is missing');
|
94
|
-
}
|
95
|
-
txb.addOutput(address, output.value);
|
96
|
-
});
|
97
|
-
if (sign === 'unsigned') {
|
98
|
-
return txb;
|
99
|
-
}
|
100
|
-
signAllTxnInputs(txb, inputs, rootWalletKeys, 'halfsigned');
|
101
|
-
if (sign === 'fullsigned') {
|
102
|
-
signAllTxnInputs(txb, inputs, rootWalletKeys, sign);
|
103
|
-
}
|
104
|
-
return txb;
|
105
|
-
}
|
106
|
-
exports.constructTxnBuilder = constructTxnBuilder;
|
107
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHJhbnNhY3Rpb24uanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvdGVzdHV0aWwvdHJhbnNhY3Rpb24udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBQUEsaUNBQWlDO0FBRWpDLDBEQUF3RjtBQUN4RixvQ0Fja0I7QUFFbEIsaUNBQXdFO0FBMkJ4RTs7R0FFRztBQUNVLFFBQUEsbUJBQW1CLEdBQUcsQ0FBQyxNQUFNLEVBQUUsV0FBVyxFQUFFLE9BQU8sRUFBRSxNQUF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