@bsv/wallet-toolbox 1.6.21 → 1.6.23
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 +4 -0
- package/docs/client.md +2 -0
- package/docs/wallet.md +2 -0
- package/mobile/out/src/CWIStyleWalletManager.d.ts +1 -0
- package/mobile/out/src/CWIStyleWalletManager.d.ts.map +1 -1
- package/mobile/out/src/CWIStyleWalletManager.js +4 -2
- package/mobile/out/src/CWIStyleWalletManager.js.map +1 -1
- package/mobile/out/src/signer/methods/buildSignableTransaction.d.ts.map +1 -1
- package/mobile/out/src/signer/methods/buildSignableTransaction.js +2 -1
- package/mobile/out/src/signer/methods/buildSignableTransaction.js.map +1 -1
- package/mobile/out/src/storage/methods/createAction.d.ts.map +1 -1
- package/mobile/out/src/storage/methods/createAction.js +4 -3
- package/mobile/out/src/storage/methods/createAction.js.map +1 -1
- package/mobile/package-lock.json +2 -2
- package/mobile/package.json +1 -1
- package/out/src/CWIStyleWalletManager.d.ts +1 -0
- package/out/src/CWIStyleWalletManager.d.ts.map +1 -1
- package/out/src/CWIStyleWalletManager.js +4 -2
- package/out/src/CWIStyleWalletManager.js.map +1 -1
- package/out/src/signer/methods/buildSignableTransaction.d.ts.map +1 -1
- package/out/src/signer/methods/buildSignableTransaction.js +2 -1
- package/out/src/signer/methods/buildSignableTransaction.js.map +1 -1
- package/out/src/storage/methods/createAction.d.ts.map +1 -1
- package/out/src/storage/methods/createAction.js +4 -3
- package/out/src/storage/methods/createAction.js.map +1 -1
- package/out/tsconfig.all.tsbuildinfo +1 -1
- package/package.json +4 -3
- package/src/CWIStyleWalletManager.ts +14 -4
- package/src/signer/methods/buildSignableTransaction.ts +2 -2
- package/src/storage/methods/createAction.ts +9 -4
- package/syncVersions.js +71 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bsv/wallet-toolbox",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.23",
|
|
4
4
|
"description": "BRC100 conforming wallet, wallet storage and wallet signer components",
|
|
5
5
|
"main": "./out/src/index.js",
|
|
6
6
|
"types": "./out/src/index.d.ts",
|
|
@@ -22,8 +22,9 @@
|
|
|
22
22
|
"test:coverage": "npm run build && jest --testPathIgnorePatterns=man.test.ts --coverage",
|
|
23
23
|
"lint": "prettier --write 'src/**/*.ts' --write 'test/**/*.ts' --log-level silent",
|
|
24
24
|
"build": "tsc --build",
|
|
25
|
-
"prepublish": "npm run lint && npm run build && npm run doc",
|
|
26
|
-
"doc": "ts2md"
|
|
25
|
+
"prepublish": "npm run lint && npm run build && npm run doc && npm run sync-versions",
|
|
26
|
+
"doc": "ts2md",
|
|
27
|
+
"sync-versions": "node syncVersions.js"
|
|
27
28
|
},
|
|
28
29
|
"bugs": {
|
|
29
30
|
"url": "https://github.com/bsv-blockchain/wallet-toolbox/issues"
|
|
@@ -61,7 +61,9 @@ import {
|
|
|
61
61
|
Transaction,
|
|
62
62
|
PushDrop,
|
|
63
63
|
CreateActionInput,
|
|
64
|
-
SHIPBroadcaster
|
|
64
|
+
SHIPBroadcaster,
|
|
65
|
+
BigNumber,
|
|
66
|
+
Curve
|
|
65
67
|
} from '@bsv/sdk'
|
|
66
68
|
import { PrivilegedKeyManager } from './sdk/PrivilegedKeyManager'
|
|
67
69
|
|
|
@@ -1065,7 +1067,13 @@ export class CWIStyleWalletManager implements WalletInterface {
|
|
|
1065
1067
|
* Lists all available profiles, including the default profile.
|
|
1066
1068
|
* @returns Array of profile info objects, including an 'active' flag.
|
|
1067
1069
|
*/
|
|
1068
|
-
listProfiles(): Array<{
|
|
1070
|
+
listProfiles(): Array<{
|
|
1071
|
+
id: number[]
|
|
1072
|
+
name: string
|
|
1073
|
+
createdAt: number | null
|
|
1074
|
+
active: boolean
|
|
1075
|
+
identityKey: string
|
|
1076
|
+
}> {
|
|
1069
1077
|
if (!this.authenticated) {
|
|
1070
1078
|
throw new Error('Not authenticated.')
|
|
1071
1079
|
}
|
|
@@ -1075,14 +1083,16 @@ export class CWIStyleWalletManager implements WalletInterface {
|
|
|
1075
1083
|
id: DEFAULT_PROFILE_ID,
|
|
1076
1084
|
name: 'default',
|
|
1077
1085
|
createdAt: null, // Default profile doesn't have a creation timestamp in the same way
|
|
1078
|
-
active: this.activeProfileId.every(x => x === 0)
|
|
1086
|
+
active: this.activeProfileId.every(x => x === 0),
|
|
1087
|
+
identityKey: new PrivateKey(this.rootPrimaryKey).toPublicKey().toString()
|
|
1079
1088
|
},
|
|
1080
1089
|
// Other profiles
|
|
1081
1090
|
...this.profiles.map(p => ({
|
|
1082
1091
|
id: p.id,
|
|
1083
1092
|
name: p.name,
|
|
1084
1093
|
createdAt: p.createdAt,
|
|
1085
|
-
active: this.activeProfileId.every((x, i) => x === p.id[i])
|
|
1094
|
+
active: this.activeProfileId.every((x, i) => x === p.id[i]),
|
|
1095
|
+
identityKey: new PrivateKey(this.XOR(this.rootPrimaryKey as number[], p.primaryPad)).toPublicKey().toString()
|
|
1086
1096
|
}))
|
|
1087
1097
|
]
|
|
1088
1098
|
return profileList
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
StorageCreateTransactionSdkInput,
|
|
6
6
|
StorageCreateTransactionSdkOutput
|
|
7
7
|
} from '../../sdk/WalletStorage.interfaces'
|
|
8
|
-
import { ValidCreateActionArgs, ValidCreateActionInput } from '../../sdk/validationHelpers'
|
|
8
|
+
import { validateSatoshis, ValidCreateActionArgs, ValidCreateActionInput } from '../../sdk/validationHelpers'
|
|
9
9
|
import { WERR_INVALID_PARAMETER } from '../../sdk/WERR_errors'
|
|
10
10
|
import { asBsvSdkScript, verifyTruthy } from '../../utility/utilityHelpers'
|
|
11
11
|
import { KeyPair } from '../../sdk/types'
|
|
@@ -143,7 +143,7 @@ export function buildSignableTransaction(
|
|
|
143
143
|
sequence: 0xffffffff
|
|
144
144
|
}
|
|
145
145
|
tx.addInput(inputToAdd)
|
|
146
|
-
totalChangeInputs +=
|
|
146
|
+
totalChangeInputs += validateSatoshis(storageInput.sourceSatoshis, 'storageInput.sourceSatoshis')
|
|
147
147
|
}
|
|
148
148
|
}
|
|
149
149
|
|
|
@@ -27,7 +27,12 @@ import {
|
|
|
27
27
|
StorageGetBeefOptions,
|
|
28
28
|
StorageProvidedBy
|
|
29
29
|
} from '../../sdk/WalletStorage.interfaces'
|
|
30
|
-
import {
|
|
30
|
+
import {
|
|
31
|
+
ValidCreateActionArgs,
|
|
32
|
+
ValidCreateActionInput,
|
|
33
|
+
ValidCreateActionOutput,
|
|
34
|
+
validateSatoshis
|
|
35
|
+
} from '../../sdk/validationHelpers'
|
|
31
36
|
import { WERR_INTERNAL, WERR_INVALID_PARAMETER } from '../../sdk/WERR_errors'
|
|
32
37
|
import {
|
|
33
38
|
randomBytesBase64,
|
|
@@ -417,7 +422,7 @@ async function createNewOutputs(
|
|
|
417
422
|
|
|
418
423
|
const ro: StorageCreateTransactionSdkOutput = {
|
|
419
424
|
vout: verifyInteger(o.vout),
|
|
420
|
-
satoshis:
|
|
425
|
+
satoshis: validateSatoshis(o.satoshis, 'o.satoshis'),
|
|
421
426
|
lockingScript: !o.lockingScript ? '' : asString(o.lockingScript),
|
|
422
427
|
providedBy: verifyTruthy(o.providedBy) as StorageProvidedBy,
|
|
423
428
|
purpose: o.purpose || undefined,
|
|
@@ -630,7 +635,7 @@ async function validateRequiredInputs(
|
|
|
630
635
|
if (!disableDoubleSpendCheckForTest && !output.spendable && !vargs.isNoSend)
|
|
631
636
|
throw new WERR_INVALID_PARAMETER(`${txid}.${vout}`, 'spendable output unless noSend is true')
|
|
632
637
|
// input is spending an existing user output which has an lockingScript
|
|
633
|
-
input.satoshis =
|
|
638
|
+
input.satoshis = validateSatoshis(output.satoshis, 'output.satoshis')
|
|
634
639
|
input.lockingScript = Script.fromBinary(asArray(output.lockingScript!))
|
|
635
640
|
} else {
|
|
636
641
|
let btx = beef.findTxid(txid)!
|
|
@@ -644,7 +649,7 @@ async function validateRequiredInputs(
|
|
|
644
649
|
// btx is valid has parsed transaction data.
|
|
645
650
|
if (vout >= btx.tx!.outputs.length) throw new WERR_INVALID_PARAMETER(`${txid}.${vout}`, 'valid outpoint')
|
|
646
651
|
const so = btx.tx!.outputs[vout]
|
|
647
|
-
input.satoshis =
|
|
652
|
+
input.satoshis = validateSatoshis(so.satoshis, 'so.satoshis')
|
|
648
653
|
input.lockingScript = so.lockingScript
|
|
649
654
|
}
|
|
650
655
|
}
|
package/syncVersions.js
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const { execSync } = require('child_process');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Synchronizes version numbers from root package.json to mobile and client package.json files
|
|
7
|
+
* and updates package-lock.json files by running npm install
|
|
8
|
+
*/
|
|
9
|
+
function syncVersions() {
|
|
10
|
+
try {
|
|
11
|
+
// Read the root package.json
|
|
12
|
+
const rootPackagePath = path.join(__dirname, 'package.json');
|
|
13
|
+
const rootPackage = JSON.parse(fs.readFileSync(rootPackagePath, 'utf8'));
|
|
14
|
+
const version = rootPackage.version;
|
|
15
|
+
|
|
16
|
+
console.log(`Root package version: ${version}`);
|
|
17
|
+
|
|
18
|
+
// Directories to update
|
|
19
|
+
const directoriesToUpdate = [
|
|
20
|
+
{ packagePath: './mobile/package.json', dir: './mobile' },
|
|
21
|
+
{ packagePath: './client/package.json', dir: './client' }
|
|
22
|
+
];
|
|
23
|
+
|
|
24
|
+
// Update each package.json file and run npm install
|
|
25
|
+
directoriesToUpdate.forEach(({ packagePath, dir }) => {
|
|
26
|
+
const fullPath = path.join(__dirname, packagePath);
|
|
27
|
+
const fullDirPath = path.join(__dirname, dir);
|
|
28
|
+
|
|
29
|
+
if (fs.existsSync(fullPath)) {
|
|
30
|
+
const packageData = JSON.parse(fs.readFileSync(fullPath, 'utf8'));
|
|
31
|
+
const oldVersion = packageData.version;
|
|
32
|
+
|
|
33
|
+
packageData.version = version;
|
|
34
|
+
fs.writeFileSync(fullPath, JSON.stringify(packageData, null, 2) + '\n');
|
|
35
|
+
|
|
36
|
+
console.log(`Updated ${packagePath}: ${oldVersion} → ${version}`);
|
|
37
|
+
|
|
38
|
+
// Run npm install to update package-lock.json
|
|
39
|
+
if (fs.existsSync(fullDirPath)) {
|
|
40
|
+
console.log(`Running npm install in ${dir}...`);
|
|
41
|
+
try {
|
|
42
|
+
execSync('npm install', {
|
|
43
|
+
cwd: fullDirPath,
|
|
44
|
+
stdio: 'inherit',
|
|
45
|
+
timeout: 60000 // 60 second timeout
|
|
46
|
+
});
|
|
47
|
+
console.log(`✓ npm install completed in ${dir}`);
|
|
48
|
+
} catch (installError) {
|
|
49
|
+
console.error(`✗ npm install failed in ${dir}:`, installError.message);
|
|
50
|
+
}
|
|
51
|
+
} else {
|
|
52
|
+
console.warn(`Warning: Directory ${dir} not found`);
|
|
53
|
+
}
|
|
54
|
+
} else {
|
|
55
|
+
console.warn(`Warning: ${packagePath} not found`);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
console.log('Version synchronization completed successfully!');
|
|
60
|
+
} catch (error) {
|
|
61
|
+
console.error('Error synchronizing versions:', error.message);
|
|
62
|
+
process.exit(1);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// Run the function if this script is executed directly
|
|
67
|
+
if (require.main === module) {
|
|
68
|
+
syncVersions();
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
module.exports = syncVersions;
|