@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.
Files changed (41) hide show
  1. package/CHANGELOG.md +3 -0
  2. package/LICENSE +21 -0
  3. package/README.md +207 -0
  4. package/package.json +67 -0
  5. package/src/address.js +97 -0
  6. package/src/block.js +177 -0
  7. package/src/bufferutils.js +56 -0
  8. package/src/crypto.js +29 -0
  9. package/src/ecdsa.js +161 -0
  10. package/src/ecpair.js +131 -0
  11. package/src/ecsignature.js +97 -0
  12. package/src/hdnode.js +316 -0
  13. package/src/index.js +23 -0
  14. package/src/networks.js +47 -0
  15. package/src/script.js +214 -0
  16. package/src/script_number.js +68 -0
  17. package/src/templates/index.js +74 -0
  18. package/src/templates/multisig/index.js +4 -0
  19. package/src/templates/multisig/input.js +71 -0
  20. package/src/templates/multisig/output.js +64 -0
  21. package/src/templates/nulldata.js +34 -0
  22. package/src/templates/pubkey/index.js +4 -0
  23. package/src/templates/pubkey/input.js +39 -0
  24. package/src/templates/pubkey/output.js +33 -0
  25. package/src/templates/pubkeyhash/index.js +4 -0
  26. package/src/templates/pubkeyhash/input.js +51 -0
  27. package/src/templates/pubkeyhash/output.js +42 -0
  28. package/src/templates/scripthash/index.js +4 -0
  29. package/src/templates/scripthash/input.js +84 -0
  30. package/src/templates/scripthash/output.js +34 -0
  31. package/src/templates/witnesscommitment/index.js +3 -0
  32. package/src/templates/witnesscommitment/output.js +42 -0
  33. package/src/templates/witnesspubkeyhash/index.js +4 -0
  34. package/src/templates/witnesspubkeyhash/input.js +44 -0
  35. package/src/templates/witnesspubkeyhash/output.js +33 -0
  36. package/src/templates/witnessscripthash/index.js +4 -0
  37. package/src/templates/witnessscripthash/input.js +63 -0
  38. package/src/templates/witnessscripthash/output.js +33 -0
  39. package/src/transaction.js +547 -0
  40. package/src/transaction_builder.js +825 -0
  41. 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