@exodus/bitcoinjs-lib-forks 0.0.1
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 +3 -0
- package/LICENSE +21 -0
- package/README.md +207 -0
- package/package.json +67 -0
- package/src/address.js +97 -0
- package/src/block.js +177 -0
- package/src/bufferutils.js +56 -0
- package/src/crypto.js +29 -0
- package/src/ecdsa.js +161 -0
- package/src/ecpair.js +131 -0
- package/src/ecsignature.js +97 -0
- package/src/hdnode.js +316 -0
- package/src/index.js +23 -0
- package/src/networks.js +47 -0
- package/src/script.js +214 -0
- package/src/script_number.js +68 -0
- package/src/templates/index.js +74 -0
- package/src/templates/multisig/index.js +4 -0
- package/src/templates/multisig/input.js +71 -0
- package/src/templates/multisig/output.js +64 -0
- package/src/templates/nulldata.js +34 -0
- package/src/templates/pubkey/index.js +4 -0
- package/src/templates/pubkey/input.js +39 -0
- package/src/templates/pubkey/output.js +33 -0
- package/src/templates/pubkeyhash/index.js +4 -0
- package/src/templates/pubkeyhash/input.js +51 -0
- package/src/templates/pubkeyhash/output.js +42 -0
- package/src/templates/scripthash/index.js +4 -0
- package/src/templates/scripthash/input.js +84 -0
- package/src/templates/scripthash/output.js +34 -0
- package/src/templates/witnesscommitment/index.js +3 -0
- package/src/templates/witnesscommitment/output.js +42 -0
- package/src/templates/witnesspubkeyhash/index.js +4 -0
- package/src/templates/witnesspubkeyhash/input.js +44 -0
- package/src/templates/witnesspubkeyhash/output.js +33 -0
- package/src/templates/witnessscripthash/index.js +4 -0
- package/src/templates/witnessscripthash/input.js +63 -0
- package/src/templates/witnessscripthash/output.js +33 -0
- package/src/transaction.js +547 -0
- package/src/transaction_builder.js +825 -0
- package/src/types.js +53 -0
package/src/types.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
var typeforce = require('typeforce')
|
|
2
|
+
|
|
3
|
+
var UINT31_MAX = Math.pow(2, 31) - 1
|
|
4
|
+
function UInt31 (value) {
|
|
5
|
+
return typeforce.UInt32(value) && value <= UINT31_MAX
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
function BIP32Path (value) {
|
|
9
|
+
return typeforce.String(value) && value.match(/^(m\/)?(\d+'?\/)*\d+'?$/)
|
|
10
|
+
}
|
|
11
|
+
BIP32Path.toJSON = function () { return 'BIP32 derivation path' }
|
|
12
|
+
|
|
13
|
+
var SATOSHI_MAX = 21 * 1e14
|
|
14
|
+
function Satoshi (value) {
|
|
15
|
+
return typeforce.UInt53(value) && value <= SATOSHI_MAX
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// external dependent types
|
|
19
|
+
var BigInt = typeforce.quacksLike('BigInteger')
|
|
20
|
+
var ECPoint = typeforce.quacksLike('Point')
|
|
21
|
+
|
|
22
|
+
// exposed, external API
|
|
23
|
+
var ECSignature = typeforce.compile({ r: BigInt, s: BigInt })
|
|
24
|
+
var Network = typeforce.compile({
|
|
25
|
+
messagePrefix: typeforce.oneOf(typeforce.Buffer, typeforce.String),
|
|
26
|
+
bip32: {
|
|
27
|
+
public: typeforce.UInt32,
|
|
28
|
+
private: typeforce.UInt32
|
|
29
|
+
},
|
|
30
|
+
pubKeyHash: typeforce.UInt8,
|
|
31
|
+
scriptHash: typeforce.UInt8,
|
|
32
|
+
wif: typeforce.UInt8
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
// extend typeforce types with ours
|
|
36
|
+
var types = {
|
|
37
|
+
BigInt: BigInt,
|
|
38
|
+
BIP32Path: BIP32Path,
|
|
39
|
+
Buffer256bit: typeforce.BufferN(32),
|
|
40
|
+
ECPoint: ECPoint,
|
|
41
|
+
ECSignature: ECSignature,
|
|
42
|
+
Hash160bit: typeforce.BufferN(20),
|
|
43
|
+
Hash256bit: typeforce.BufferN(32),
|
|
44
|
+
Network: Network,
|
|
45
|
+
Satoshi: Satoshi,
|
|
46
|
+
UInt31: UInt31
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
for (var typeName in typeforce) {
|
|
50
|
+
types[typeName] = typeforce[typeName]
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
module.exports = types
|