bsv2 2.0.15 → 2.0.16
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/bsv.bundle.js +1 -1
- package/dist/bsv.bundle.js.map +1 -1
- package/dist/bsv.cjs.js +1 -1
- package/dist/bsv.cjs.js.map +1 -1
- package/dist/bsv.module.js +1 -1
- package/dist/bsv.module.js.map +1 -1
- package/dist/bsv2.bundle.js +3 -0
- package/dist/bsv2.bundle.js.LICENSE.txt +10 -0
- package/dist/bsv2.bundle.js.map +1 -0
- package/dist/bsv2.cjs.js +3 -0
- package/dist/bsv2.cjs.js.LICENSE.txt +1 -0
- package/dist/bsv2.cjs.js.map +1 -0
- package/dist/bsv2.mjs +3 -0
- package/dist/bsv2.mjs.LICENSE.txt +10 -0
- package/dist/bsv2.mjs.map +1 -0
- package/dist/bsv2.module.js +3 -0
- package/dist/bsv2.module.js.LICENSE.txt +1 -0
- package/dist/bsv2.module.js.map +1 -0
- package/lib/bip-39.js +15 -5
- package/lib/tx-builder.js +4 -9
- package/mtest/test.html +15 -0
- package/mtest/test.js +2 -0
- package/mtest/test.mjs +2 -0
- package/package.json +7 -5
- package/webpack.config.js +22 -5
- package/build/bsv.js +0 -3
- package/dist/bsv.min.js +0 -2
- package/jsdoc.json +0 -5
- package/lib/rabin.js +0 -300
- package/mkdocs.yml +0 -37
- package/webpack.config.js_entry +0 -57
- package/yarn-error.log +0 -6199
package/lib/bip-39.js
CHANGED
|
@@ -21,15 +21,25 @@ import { Hash } from './hash'
|
|
|
21
21
|
import pbkdf2 from 'pbkdf2'
|
|
22
22
|
import { Random } from './random'
|
|
23
23
|
import { Struct } from './struct'
|
|
24
|
-
import {
|
|
24
|
+
import {en, es, jp} from './bip-39-words'
|
|
25
25
|
import { Workers } from './workers'
|
|
26
26
|
|
|
27
27
|
class Bip39 extends Struct {
|
|
28
|
-
constructor (mnemonic, seed, wordlist
|
|
29
|
-
super({ mnemonic, seed })
|
|
30
|
-
|
|
28
|
+
constructor (mnemonic, seed, wordlist ) {
|
|
29
|
+
super({ mnemonic, seed, wordlist })
|
|
30
|
+
this.Wordlist = en
|
|
31
|
+
this.es = es
|
|
32
|
+
this.jp = jp
|
|
33
|
+
|
|
31
34
|
}
|
|
32
35
|
|
|
36
|
+
setLang (lang){
|
|
37
|
+
switch(lang){
|
|
38
|
+
default: case "en": this.Wordlist = en; break;
|
|
39
|
+
case "es": this.Wordlist = es; break;
|
|
40
|
+
case "jp": this.Wordlist = jp; break;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
33
43
|
toBw (bw) {
|
|
34
44
|
if (!bw) {
|
|
35
45
|
bw = new Bw()
|
|
@@ -129,7 +139,7 @@ class Bip39 extends Struct {
|
|
|
129
139
|
}
|
|
130
140
|
|
|
131
141
|
fromString (mnemonic) {
|
|
132
|
-
this.mnemonic = mnemonic
|
|
142
|
+
this.mnemonic = mnemonic.trim()
|
|
133
143
|
return this
|
|
134
144
|
}
|
|
135
145
|
|
package/lib/tx-builder.js
CHANGED
|
@@ -240,7 +240,7 @@ class TxBuilder extends Struct {
|
|
|
240
240
|
let outAmountBn = new Bn(0)
|
|
241
241
|
this.txOuts.forEach(txOut => {
|
|
242
242
|
if (txOut.valueBn.lt(this.dust) && !txOut.script.isNonSpendable()) {
|
|
243
|
-
throw new Error('cannot create output lesser than dust
|
|
243
|
+
throw new Error('cannot create output lesser than dust')
|
|
244
244
|
}
|
|
245
245
|
outAmountBn = outAmountBn.add(txOut.valueBn)
|
|
246
246
|
this.tx.addTxOut(txOut)
|
|
@@ -366,18 +366,13 @@ class TxBuilder extends Struct {
|
|
|
366
366
|
break
|
|
367
367
|
}
|
|
368
368
|
}
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
this.tx.txOuts.pop()
|
|
372
|
-
this.tx.txOutsVi = VarInt.fromNumber(this.tx.txOutsVi.toNumber() - 1)
|
|
373
|
-
|
|
374
|
-
}else if (this.changeAmountBn.geq(minFeeAmountBn)) {
|
|
375
|
-
// Substract fee from change
|
|
369
|
+
if (this.changeAmountBn.geq(minFeeAmountBn)) {
|
|
370
|
+
// Subtract fee from change
|
|
376
371
|
this.feeAmountBn = minFeeAmountBn
|
|
377
372
|
this.changeAmountBn = this.changeAmountBn.sub(this.feeAmountBn)
|
|
378
373
|
this.tx.txOuts[this.tx.txOuts.length - 1].valueBn = this.changeAmountBn
|
|
379
374
|
|
|
380
|
-
if (this.changeAmountBn.lt(this.dust)
|
|
375
|
+
if (this.changeAmountBn.lt(this.dust)) {
|
|
381
376
|
if (this.dustChangeToFees) {
|
|
382
377
|
// Remove the change amount since it is less than dust and the
|
|
383
378
|
// builder has requested dust be sent to fees.
|
package/mtest/test.html
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
6
|
+
<title>Test</title>
|
|
7
|
+
<script type="text/javascript" src="../dist/bsv2.bundle.js"></script>
|
|
8
|
+
<script type="text/javascript">
|
|
9
|
+
console.log(bsv2)
|
|
10
|
+
</script>
|
|
11
|
+
</head>
|
|
12
|
+
<body>
|
|
13
|
+
|
|
14
|
+
</body>
|
|
15
|
+
</html>
|
package/mtest/test.js
ADDED
package/mtest/test.mjs
ADDED
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bsv2",
|
|
3
3
|
"description": "Javascript library for Bitcoin SV (BSV).",
|
|
4
|
-
"version": "2.0.
|
|
4
|
+
"version": "2.0.16",
|
|
5
5
|
"author": "Tomás Díaz",
|
|
6
6
|
"homepage": "https://github.com/samooth/bsv",
|
|
7
7
|
"source": "entry.js",
|
|
8
|
-
"main": "dist/
|
|
9
|
-
"module": "dist/
|
|
10
|
-
"unpkg": "dist/
|
|
11
|
-
"library": "
|
|
8
|
+
"main": "dist/bsv2.cjs.js",
|
|
9
|
+
"module": "dist/bsv2.mjs",
|
|
10
|
+
"unpkg": "dist/bsv2.bundle.js",
|
|
11
|
+
"library": "bsv2",
|
|
12
12
|
"scripts": {
|
|
13
13
|
"clean": "rm -rf node_modules/* yarn.lock",
|
|
14
14
|
"lint": "standard *.js lib/**/*.js bin/**/*.js test/**/*.js",
|
|
@@ -79,6 +79,8 @@
|
|
|
79
79
|
"bsv",
|
|
80
80
|
"blockchain",
|
|
81
81
|
"bip32",
|
|
82
|
+
"bip38",
|
|
83
|
+
"bip44",
|
|
82
84
|
"bip39",
|
|
83
85
|
"bip68",
|
|
84
86
|
"multisig",
|
package/webpack.config.js
CHANGED
|
@@ -8,9 +8,9 @@ module.exports = [
|
|
|
8
8
|
target: 'web',
|
|
9
9
|
output: {
|
|
10
10
|
path: path.resolve(__dirname, 'dist'),
|
|
11
|
-
filename: '
|
|
11
|
+
filename: 'bsv2.bundle.js',
|
|
12
12
|
library: {
|
|
13
|
-
name: '
|
|
13
|
+
name: 'bsv2',
|
|
14
14
|
type: 'umd2'
|
|
15
15
|
}
|
|
16
16
|
},
|
|
@@ -25,7 +25,9 @@ module.exports = [
|
|
|
25
25
|
plugins: [
|
|
26
26
|
new webpack.ProvidePlugin({
|
|
27
27
|
process: 'process/browser',
|
|
28
|
-
|
|
28
|
+
}),
|
|
29
|
+
new webpack.ProvidePlugin({
|
|
30
|
+
Buffer: ['buffer', 'Buffer']
|
|
29
31
|
})
|
|
30
32
|
],
|
|
31
33
|
devtool: 'source-map',
|
|
@@ -36,21 +38,36 @@ module.exports = [
|
|
|
36
38
|
target: 'node',
|
|
37
39
|
output: {
|
|
38
40
|
path: path.resolve(__dirname, 'dist'),
|
|
39
|
-
filename: '
|
|
41
|
+
filename: 'bsv2.module.js',
|
|
40
42
|
library: {
|
|
43
|
+
name: 'bsv2',
|
|
41
44
|
type: 'commonjs-module'
|
|
42
45
|
}
|
|
43
46
|
},
|
|
44
47
|
devtool: 'source-map',
|
|
45
48
|
mode: 'production'
|
|
46
49
|
},
|
|
50
|
+
{
|
|
51
|
+
entry: './entry.js',
|
|
52
|
+
experiments:{outputModule:true},
|
|
53
|
+
output: {
|
|
54
|
+
path: path.resolve(__dirname, 'dist'),
|
|
55
|
+
filename: 'bsv2.mjs',
|
|
56
|
+
library: {
|
|
57
|
+
type: 'module'
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
devtool: 'source-map',
|
|
61
|
+
mode: 'production'
|
|
62
|
+
},
|
|
47
63
|
{
|
|
48
64
|
entry: './entry.js',
|
|
49
65
|
target: 'node',
|
|
50
66
|
output: {
|
|
51
67
|
path: path.resolve(__dirname, 'dist'),
|
|
52
|
-
filename: '
|
|
68
|
+
filename: 'bsv2.cjs.js',
|
|
53
69
|
library: {
|
|
70
|
+
name: 'bsv2',
|
|
54
71
|
type: 'commonjs2'
|
|
55
72
|
}
|
|
56
73
|
},
|