@bitgo-beta/unspents 0.13.2-beta.9 → 0.13.2-beta.91
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/CHANGELOG.md +60 -0
- package/bin/generate_tables.ts +94 -0
- package/dist/bin/generate_tables.d.ts +2 -0
- package/dist/bin/generate_tables.d.ts.map +1 -0
- package/dist/bin/generate_tables.js +94 -0
- package/dist/{codes.d.ts → src/codes.d.ts} +1 -0
- package/dist/src/codes.d.ts.map +1 -0
- package/dist/src/codes.js +168 -0
- package/dist/{dimensions.d.ts → src/dimensions.d.ts} +6 -7
- package/dist/src/dimensions.d.ts.map +1 -0
- package/dist/src/dimensions.js +485 -0
- package/dist/{index.d.ts → src/index.d.ts} +1 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/{index.js → src/index.js} +1 -1
- package/dist/{inputWeights.d.ts → src/inputWeights.d.ts} +1 -0
- package/dist/src/inputWeights.d.ts.map +1 -0
- package/dist/src/inputWeights.js +97 -0
- package/dist/{scriptSizes.d.ts → src/scriptSizes.d.ts} +1 -0
- package/dist/src/scriptSizes.d.ts.map +1 -0
- package/dist/src/scriptSizes.js +51 -0
- package/dist/{types.d.ts → src/types.d.ts} +1 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/{types.js → src/types.js} +1 -1
- package/dist/{virtualSizes.d.ts → src/virtualSizes.d.ts} +1 -0
- package/dist/src/virtualSizes.d.ts.map +1 -0
- package/dist/src/virtualSizes.js +114 -0
- package/dist/test/chain.d.ts +2 -0
- package/dist/test/chain.d.ts.map +1 -0
- package/dist/test/chain.js +92 -0
- package/dist/test/dimensions.d.ts +2 -0
- package/dist/test/dimensions.d.ts.map +1 -0
- package/dist/test/dimensions.js +211 -0
- package/dist/test/signedTx/inputWeights.d.ts +2 -0
- package/dist/test/signedTx/inputWeights.d.ts.map +1 -0
- package/dist/test/signedTx/inputWeights.js +113 -0
- package/dist/test/signedTx/txCombinations.d.ts +3 -0
- package/dist/test/signedTx/txCombinations.d.ts.map +1 -0
- package/dist/test/signedTx/txCombinations.js +116 -0
- package/dist/test/signedTx/txGen.d.ts +75 -0
- package/dist/test/signedTx/txGen.d.ts.map +1 -0
- package/dist/test/signedTx/txGen.js +219 -0
- package/dist/test/testutils.d.ts +36 -0
- package/dist/test/testutils.d.ts.map +1 -0
- package/dist/test/testutils.js +176 -0
- package/dist/test/virtualSizes.d.ts +2 -0
- package/dist/test/virtualSizes.d.ts.map +1 -0
- package/dist/test/virtualSizes.js +18 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/docs/input-costs.md +13 -0
- package/package.json +5 -5
- package/dist/codes.js +0 -168
- package/dist/dimensions.js +0 -490
- package/dist/inputWeights.js +0 -97
- package/dist/scriptSizes.js +0 -51
- package/dist/virtualSizes.js +0 -114
package/dist/virtualSizes.js
DELETED
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
This is a reference implementation for calculating weights and vSizes from bitcoinjs-lib 3.3.2.
|
|
4
|
-
https://github.com/bitcoinjs/bitcoinjs-lib/blob/v3.3.2/src/transaction.js#L194-L219
|
|
5
|
-
|
|
6
|
-
```
|
|
7
|
-
function encodingLength (number) {
|
|
8
|
-
checkUInt53(number)
|
|
9
|
-
|
|
10
|
-
return (
|
|
11
|
-
number < 0xfd ? 1
|
|
12
|
-
: number <= 0xffff ? 3
|
|
13
|
-
: number <= 0xffffffff ? 5
|
|
14
|
-
: 9
|
|
15
|
-
)
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
function varSliceSize (someScript) {
|
|
19
|
-
var length = someScript.length
|
|
20
|
-
|
|
21
|
-
return encodingLength(length) + length
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
function vectorSize (someVector) {
|
|
25
|
-
var length = someVector.length
|
|
26
|
-
|
|
27
|
-
return varuint.encodingLength(length) + someVector.reduce(function (sum, witness) {
|
|
28
|
-
return sum + varSliceSize(witness)
|
|
29
|
-
}, 0)
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
Transaction.prototype.__byteLength = function (__allowWitness) {
|
|
33
|
-
var hasWitnesses = __allowWitness && this.hasWitnesses()
|
|
34
|
-
|
|
35
|
-
return (
|
|
36
|
-
(hasWitnesses ? 10 : 8) +
|
|
37
|
-
varuint.encodingLength(this.ins.length) +
|
|
38
|
-
varuint.encodingLength(this.outs.length) +
|
|
39
|
-
this.ins.reduce(function (sum, input) { return sum + 40 + varSliceSize(input.script) }, 0) +
|
|
40
|
-
this.outs.reduce(function (sum, output) { return sum + 8 + varSliceSize(output.script) }, 0) +
|
|
41
|
-
(hasWitnesses ? this.ins.reduce(function (sum, input) { return sum + vectorSize(input.witness) }, 0) : 0)
|
|
42
|
-
)
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
Transaction.prototype.weight = function () {
|
|
46
|
-
var base = this.__byteLength(false)
|
|
47
|
-
var total = this.__byteLength(true)
|
|
48
|
-
return base * 3 + total
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
Transaction.prototype.virtualSize = function () {
|
|
52
|
-
return Math.ceil(this.weight() / 4)
|
|
53
|
-
}
|
|
54
|
-
```
|
|
55
|
-
*/
|
|
56
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
57
|
-
exports.VirtualSizes = void 0;
|
|
58
|
-
const inputWeights_1 = require("./inputWeights");
|
|
59
|
-
function getVirtualInputSizeFromComponents(components) {
|
|
60
|
-
return Math.ceil(inputWeights_1.getInputComponentsWeight(components) / 4);
|
|
61
|
-
}
|
|
62
|
-
// Constants for signed TX input and output vsizes.
|
|
63
|
-
// See https://bitcoincore.org/en/segwit_wallet_dev/#transaction-serialization for full description
|
|
64
|
-
// FIXME(BG-9233): use weight units instead
|
|
65
|
-
exports.VirtualSizes = Object.freeze({
|
|
66
|
-
// FIXME(BG-7873): add support for signature grinding
|
|
67
|
-
// Size of a P2PKH input with (un)compressed key
|
|
68
|
-
/** @deprecated */
|
|
69
|
-
txP2pkhInputSizeCompressedKey: 148,
|
|
70
|
-
/** @deprecated */
|
|
71
|
-
txP2pkhInputSizeUncompressedKey: 180,
|
|
72
|
-
// Input sizes
|
|
73
|
-
txP2shInputSize: getVirtualInputSizeFromComponents(inputWeights_1.inputComponentsP2sh),
|
|
74
|
-
txP2shP2wshInputSize: getVirtualInputSizeFromComponents(inputWeights_1.inputComponentsP2shP2wsh),
|
|
75
|
-
txP2wshInputSize: getVirtualInputSizeFromComponents(inputWeights_1.inputComponentsP2wsh),
|
|
76
|
-
txP2trKeypathInputSize: getVirtualInputSizeFromComponents(inputWeights_1.inputComponentsP2trKeySpend),
|
|
77
|
-
txP2shP2pkInputSize: getVirtualInputSizeFromComponents(inputWeights_1.inputComponentsP2shP2pk),
|
|
78
|
-
txP2trScriptPathLevel1InputSize: getVirtualInputSizeFromComponents(inputWeights_1.inputComponentsP2trScriptSpendLevel1),
|
|
79
|
-
txP2trScriptPathLevel2InputSize: getVirtualInputSizeFromComponents(inputWeights_1.inputComponentsP2trScriptSpendLevel2),
|
|
80
|
-
//
|
|
81
|
-
// Output sizes
|
|
82
|
-
//
|
|
83
|
-
// The size is calculated as
|
|
84
|
-
//
|
|
85
|
-
// scriptLength + compactSize(scriptLength) + txOutputAmountSize
|
|
86
|
-
//
|
|
87
|
-
// Since compactSize(scriptLength) is 1 for all scripts considered here, we can simplify this to
|
|
88
|
-
//
|
|
89
|
-
// scriptLength + 9
|
|
90
|
-
//
|
|
91
|
-
// Size of single output amount
|
|
92
|
-
txOutputAmountSize: 8,
|
|
93
|
-
// https://github.com/bitcoinjs/bitcoinjs-lib/blob/v4.0.2/src/templates/scripthash/output.js#L9
|
|
94
|
-
txP2shOutputSize: 32,
|
|
95
|
-
txP2shP2wshOutputSize: 32,
|
|
96
|
-
// https://github.com/bitcoinjs/bitcoinjs-lib/blob/v4.0.2/src/templates/witnessscripthash/output.js#L9
|
|
97
|
-
txP2wshOutputSize: 43,
|
|
98
|
-
// OP_1 OP_PUSH32 <schnorr_public_key>
|
|
99
|
-
txP2trOutputSize: 43,
|
|
100
|
-
// https://github.com/bitcoinjs/bitcoinjs-lib/blob/v4.0.2/src/templates/pubkeyhash/output.js#L9
|
|
101
|
-
txP2pkhOutputSize: 34,
|
|
102
|
-
// https://github.com/bitcoinjs/bitcoinjs-lib/blob/v4.0.2/src/templates/witnesspubkeyhash/output.js#L9
|
|
103
|
-
txP2wpkhOutputSize: 31,
|
|
104
|
-
/** @deprecated - use txP2pkhOutputSize instead */
|
|
105
|
-
txOutputSize: 34,
|
|
106
|
-
//
|
|
107
|
-
// General tx size constants
|
|
108
|
-
//
|
|
109
|
-
txOverheadSize: 10,
|
|
110
|
-
// Segwit adds one byte each for marker and flag to the witness section.
|
|
111
|
-
// Thus, the vsize is only increased by one.
|
|
112
|
-
txSegOverheadVSize: 11,
|
|
113
|
-
});
|
|
114
|
-
//# sourceMappingURL=virtualSizes.js.map
|