@bsv/wallet-toolbox 1.1.3 → 1.1.5
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/docs/README.md +1 -0
- package/docs/client.md +301 -73
- package/docs/setup.md +376 -69
- package/docs/storage.md +1 -1
- package/docs/wallet.md +301 -73
- package/license.md +28 -1
- package/out/src/Setup.d.ts +52 -30
- package/out/src/Setup.d.ts.map +1 -1
- package/out/src/Setup.js +26 -10
- package/out/src/Setup.js.map +1 -1
- package/out/src/SetupClient.d.ts +121 -41
- package/out/src/SetupClient.d.ts.map +1 -1
- package/out/src/SetupClient.js +138 -89
- package/out/src/SetupClient.js.map +1 -1
- package/out/src/Wallet.d.ts +10 -0
- package/out/src/Wallet.d.ts.map +1 -1
- package/out/src/Wallet.js.map +1 -1
- package/out/src/index.all.d.ts +1 -1
- package/out/src/index.all.d.ts.map +1 -1
- package/out/src/index.all.js +3 -2
- package/out/src/index.all.js.map +1 -1
- package/out/src/sdk/types.d.ts +5 -0
- package/out/src/sdk/types.d.ts.map +1 -1
- package/out/src/sdk/types.js.map +1 -1
- package/out/src/storage/WalletStorageManager.d.ts +1 -1
- package/out/src/storage/WalletStorageManager.js +1 -1
- package/out/src/storage/methods/listOutputs.d.ts.map +1 -1
- package/out/src/storage/methods/listOutputs.js +4 -2
- package/out/src/storage/methods/listOutputs.js.map +1 -1
- package/out/src/utility/ScriptTemplateSABPPP.d.ts +4 -0
- package/out/src/utility/ScriptTemplateSABPPP.d.ts.map +1 -1
- package/out/src/utility/ScriptTemplateSABPPP.js +4 -0
- package/out/src/utility/ScriptTemplateSABPPP.js.map +1 -1
- package/out/test/examples/README.man.test.js +8 -7
- package/out/test/examples/README.man.test.js.map +1 -1
- package/out/test/wallet/list/listOutputs.test.js +8 -12
- package/out/test/wallet/list/listOutputs.test.js.map +1 -1
- package/out/tsconfig.all.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/Setup.ts +65 -54
- package/src/SetupClient.ts +241 -150
- package/src/Wallet.ts +10 -0
- package/src/index.all.ts +9 -1
- package/src/sdk/types.ts +7 -0
- package/src/storage/WalletStorageManager.ts +1 -1
- package/src/storage/methods/listOutputs.ts +4 -2
- package/src/utility/ScriptTemplateSABPPP.ts +4 -0
- package/test/examples/README.man.test.ts +9 -9
- package/test/wallet/list/listOutputs.test.ts +7 -13
- package/ts2md.json +0 -8
- package/tsconfig.all.json +1 -1
- package/LICENSE.txt +0 -28
- package/dev.sqlite3 +0 -0
- package/knexfile.js +0 -9
package/out/src/Setup.js
CHANGED
|
@@ -5,25 +5,30 @@ const index_client_1 = require("./index.client");
|
|
|
5
5
|
const knex_1 = require("knex");
|
|
6
6
|
const index_all_1 = require("./index.all");
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
8
|
+
* The 'Setup` class provides static setup functions to construct BRC-100 compatible
|
|
9
9
|
* wallets in a variety of configurations.
|
|
10
10
|
*
|
|
11
11
|
* It serves as a starting point for experimentation and customization.
|
|
12
12
|
*
|
|
13
|
+
* `SetupClient` references only browser compatible code including storage via `StorageClient`.
|
|
14
|
+
* `Setup` extends `SetupClient` adding database storage via `Knex` and `StorageKnex`.
|
|
15
|
+
*
|
|
13
16
|
*/
|
|
14
17
|
class Setup extends index_client_1.SetupClient {
|
|
15
18
|
/**
|
|
16
19
|
* Adds `Knex` based storage to a `Wallet` configured by `Setup.createWalletOnly`
|
|
17
20
|
*
|
|
18
|
-
* @param args
|
|
19
|
-
*
|
|
21
|
+
* @param args.knex `Knex` object configured for either MySQL or SQLite database access.
|
|
22
|
+
* Schema will be created and migrated as needed.
|
|
23
|
+
* For MySQL, a schema corresponding to databaseName must exist with full access permissions.
|
|
24
|
+
* @param args.databaseName Name for this storage. For MySQL, the schema name within the MySQL instance.
|
|
25
|
+
* @param args.chain Which chain this wallet is on: 'main' or 'test'. Defaults to 'test'.
|
|
26
|
+
* @param args.rootKeyHex
|
|
27
|
+
*
|
|
28
|
+
* @publicbody
|
|
20
29
|
*/
|
|
21
30
|
static async createKnexWallet(args) {
|
|
22
|
-
const wo = await Setup.
|
|
23
|
-
chain: args.chain,
|
|
24
|
-
rootKeyHex: args.rootKeyHex,
|
|
25
|
-
privKeyHex: args.privKeyHex
|
|
26
|
-
});
|
|
31
|
+
const wo = await Setup.createWallet(args);
|
|
27
32
|
const activeStorage = new index_all_1.StorageKnex({
|
|
28
33
|
chain: wo.chain,
|
|
29
34
|
knex: args.knex,
|
|
@@ -43,6 +48,9 @@ class Setup extends index_client_1.SetupClient {
|
|
|
43
48
|
};
|
|
44
49
|
return r;
|
|
45
50
|
}
|
|
51
|
+
/**
|
|
52
|
+
* @publicbody
|
|
53
|
+
*/
|
|
46
54
|
static createSQLiteKnex(filename) {
|
|
47
55
|
const config = {
|
|
48
56
|
client: 'sqlite3',
|
|
@@ -52,6 +60,9 @@ class Setup extends index_client_1.SetupClient {
|
|
|
52
60
|
const knex = (0, knex_1.knex)(config);
|
|
53
61
|
return knex;
|
|
54
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* @publicbody
|
|
65
|
+
*/
|
|
55
66
|
static createMySQLKnex(connection, database) {
|
|
56
67
|
const c = JSON.parse(connection);
|
|
57
68
|
if (database) {
|
|
@@ -66,13 +77,18 @@ class Setup extends index_client_1.SetupClient {
|
|
|
66
77
|
const knex = (0, knex_1.knex)(config);
|
|
67
78
|
return knex;
|
|
68
79
|
}
|
|
80
|
+
/**
|
|
81
|
+
* @publicbody
|
|
82
|
+
*/
|
|
69
83
|
static async createMySQLWallet(args) {
|
|
70
|
-
const env = Setup.getEnv(args.chain || 'test');
|
|
71
84
|
return await this.createKnexWallet({
|
|
72
85
|
...args,
|
|
73
|
-
knex: Setup.createMySQLKnex(env.mySQLConnection, args.databaseName)
|
|
86
|
+
knex: Setup.createMySQLKnex(args.env.mySQLConnection, args.databaseName)
|
|
74
87
|
});
|
|
75
88
|
}
|
|
89
|
+
/**
|
|
90
|
+
* @publicbody
|
|
91
|
+
*/
|
|
76
92
|
static async createSQLiteWallet(args) {
|
|
77
93
|
return await this.createKnexWallet({
|
|
78
94
|
...args,
|
package/out/src/Setup.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Setup.js","sourceRoot":"","sources":["../../src/Setup.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"Setup.js","sourceRoot":"","sources":["../../src/Setup.ts"],"names":[],"mappings":";;;AACA,iDAOuB;AACvB,+BAA6C;AAC7C,2CAAuE;AAEvE;;;;;;;;;GASG;AACH,MAAsB,KAAM,SAAQ,0BAAW;IAC7C;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,KAAK,CAAC,gBAAgB,CAC3B,IAAyB;QAEzB,MAAM,EAAE,GAAG,MAAM,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,CAAA;QACzC,MAAM,aAAa,GAAG,IAAI,uBAAW,CAAC;YACpC,KAAK,EAAE,EAAE,CAAC,KAAK;YACf,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,kBAAkB,EAAE,CAAC;YACrB,mBAAmB,EAAE,SAAS;YAC9B,QAAQ,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,EAAE;SACxC,CAAC,CAAA;QACF,MAAM,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,YAAY,EAAE,EAAE,CAAC,WAAW,CAAC,CAAA;QAC9D,MAAM,aAAa,CAAC,aAAa,EAAE,CAAA;QACnC,MAAM,EAAE,CAAC,OAAO,CAAC,wBAAwB,CAAC,aAAa,CAAC,CAAA;QACxD,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,aAAa,CAAC,gBAAgB,CAAC,EAAE,CAAC,WAAW,CAAC,CAAA;QAC5E,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAA;QAC1B,MAAM,CAAC,GAAoB;YACzB,GAAG,EAAE;YACL,aAAa;YACb,MAAM;SACP,CAAA;QACD,OAAO,CAAC,CAAA;IAC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AC,IAAI,CAAC,QAAQ,CAAC;SAC5C,CAAC,CAAA;IACJ,CAAC;CACF;AA3FD,sBA2FC"}
|
package/out/src/SetupClient.d.ts
CHANGED
|
@@ -1,60 +1,134 @@
|
|
|
1
|
-
import { CreateActionResult, KeyDeriver, PrivateKey, PublicKey,
|
|
1
|
+
import { BEEF, CreateActionOptions, CreateActionOutput, CreateActionResult, KeyDeriver, PrivateKey, PublicKey, WalletInterface } from '@bsv/sdk';
|
|
2
2
|
import { Monitor, sdk, Services, Wallet, WalletStorageManager } from './index.client';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* The `SetupClient` class provides static setup functions to construct BRC-100 compatible
|
|
5
5
|
* wallets in a variety of configurations.
|
|
6
6
|
*
|
|
7
7
|
* It serves as a starting point for experimentation and customization.
|
|
8
8
|
*
|
|
9
|
+
* `SetupClient` references only browser compatible code including storage via `StorageClient`.
|
|
10
|
+
* `Setup` extends `SetupClient` adding database storage via `Knex` and `StorageKnex`.
|
|
11
|
+
*
|
|
9
12
|
*/
|
|
10
13
|
export declare abstract class SetupClient {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
static
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Creates content for .env file with some private keys, identity keys, sample API keys, and sample MySQL connection string.
|
|
16
|
+
*
|
|
17
|
+
* Two new, random private keys are generated each time, with their associated public identity keys.
|
|
18
|
+
*
|
|
19
|
+
* Loading secrets from a .env file is intended only for experimentation and getting started.
|
|
20
|
+
* Private keys should never be included directly in your source code.
|
|
21
|
+
*
|
|
22
|
+
* @publicBody
|
|
23
|
+
*/
|
|
24
|
+
static makeEnv(): string;
|
|
25
|
+
/**
|
|
26
|
+
* Reads a .env file of the format created by `makeEnv`.
|
|
27
|
+
*
|
|
28
|
+
* Returns values for designated `chain`.
|
|
29
|
+
*
|
|
30
|
+
* Access private keys through the `devKeys` object: `devKeys[identityKey]`
|
|
31
|
+
*
|
|
32
|
+
* @param chain Which chain to use: 'test' or 'main'
|
|
33
|
+
* @returns {SetupEnv} with configuration environment secrets used by `Setup` functions.
|
|
34
|
+
*
|
|
35
|
+
* @publicBody
|
|
36
|
+
*/
|
|
37
|
+
static getEnv(chain: sdk.Chain): SetupEnv;
|
|
38
|
+
/**
|
|
39
|
+
* Create a `Wallet`. Storage can optionally be provided or configured later.
|
|
40
|
+
*
|
|
41
|
+
* The following components are configured: KeyDeriver, WalletStorageManager, WalletService, WalletStorage.
|
|
42
|
+
* Optionally, PrivilegedKeyManager is also configured.
|
|
43
|
+
*
|
|
44
|
+
* @publicbody
|
|
45
|
+
*/
|
|
46
|
+
static createWallet(args: SetupWalletArgs): Promise<SetupWallet>;
|
|
47
|
+
/**
|
|
48
|
+
* @publicBody
|
|
49
|
+
*/
|
|
50
|
+
static createWalletWithStorageClient(args: SetupWalletClientArgs): Promise<SetupWalletClient>;
|
|
51
|
+
/**
|
|
52
|
+
* @publicBody
|
|
53
|
+
*/
|
|
33
54
|
static getKeyPair(priv?: string | PrivateKey): KeyPairAddress;
|
|
55
|
+
/**
|
|
56
|
+
* @publicBody
|
|
57
|
+
*/
|
|
34
58
|
static getLockP2PKH(address: string): import("@bsv/sdk").LockingScript;
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
59
|
+
/**
|
|
60
|
+
* @publicBody
|
|
61
|
+
*/
|
|
62
|
+
static getUnlockP2PKH(priv: PrivateKey, satoshis: number): sdk.ScriptTemplateUnlock;
|
|
63
|
+
/**
|
|
64
|
+
* @publicBody
|
|
65
|
+
*/
|
|
66
|
+
static createP2PKHOutputs(outputs: {
|
|
67
|
+
address: string;
|
|
68
|
+
satoshis: number;
|
|
69
|
+
outputDescription?: string;
|
|
70
|
+
basket?: string;
|
|
71
|
+
tags?: string[];
|
|
72
|
+
}[]): CreateActionOutput[];
|
|
73
|
+
/**
|
|
74
|
+
* @publicBody
|
|
75
|
+
*/
|
|
76
|
+
static createP2PKHOutputsAction(wallet: WalletInterface, outputs: {
|
|
77
|
+
address: string;
|
|
78
|
+
satoshis: number;
|
|
79
|
+
outputDescription?: string;
|
|
80
|
+
basket?: string;
|
|
81
|
+
tags?: string[];
|
|
82
|
+
}[], options?: CreateActionOptions): Promise<{
|
|
83
|
+
cr: CreateActionResult;
|
|
84
|
+
outpoints: string[] | undefined;
|
|
85
|
+
}>;
|
|
86
|
+
/**
|
|
87
|
+
* @publicBody
|
|
88
|
+
*/
|
|
89
|
+
static fundWalletFromP2PKHOutpoints(wallet: WalletInterface, outpoints: string[], p2pkhKey: KeyPairAddress, inputBEEF?: BEEF): Promise<void>;
|
|
51
90
|
}
|
|
91
|
+
/**
|
|
92
|
+
*
|
|
93
|
+
*/
|
|
52
94
|
export type KeyPairAddress = {
|
|
53
95
|
privateKey: PrivateKey;
|
|
54
96
|
publicKey: PublicKey;
|
|
55
97
|
address: string;
|
|
56
98
|
};
|
|
57
|
-
|
|
99
|
+
/**
|
|
100
|
+
*
|
|
101
|
+
*/
|
|
102
|
+
export interface SetupEnv {
|
|
103
|
+
chain: sdk.Chain;
|
|
104
|
+
identityKey: string;
|
|
105
|
+
identityKey2: string;
|
|
106
|
+
taalApiKey: string;
|
|
107
|
+
devKeys: Record<string, string>;
|
|
108
|
+
mySQLConnection: string;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Arguments used to construct a `Wallet`
|
|
112
|
+
*
|
|
113
|
+
* @param env Configuration "secrets" typically obtained by `Setup.makeEnv` and `Setup.getEnv` functions.
|
|
114
|
+
* @param chain Optional. Which chain this wallet is on: 'main' or 'test'.
|
|
115
|
+
* Defaults to `env.chain`.
|
|
116
|
+
* @param rootKeyHex Optional. The non-privileged private key used to initialize the `KeyDeriver` and determine the `identityKey`.
|
|
117
|
+
* Defaults to `env.devKeys[env.identityKey]
|
|
118
|
+
* @param privKeyHex Optional. The privileged private key used to initialize the `PrivilegedKeyManager`.
|
|
119
|
+
* Defaults to undefined.
|
|
120
|
+
* @param active. Optional. Active wallet storage. Can be added later.
|
|
121
|
+
* @param backups. Optional. One or more storage providers managed as backup destinations. Can be added later.
|
|
122
|
+
*/
|
|
123
|
+
export interface SetupWalletArgs {
|
|
124
|
+
env: SetupEnv;
|
|
125
|
+
chain?: sdk.Chain;
|
|
126
|
+
rootKeyHex?: string;
|
|
127
|
+
privKeyHex?: string;
|
|
128
|
+
active?: sdk.WalletStorageProvider;
|
|
129
|
+
backups?: sdk.WalletStorageProvider[];
|
|
130
|
+
}
|
|
131
|
+
export interface SetupWallet {
|
|
58
132
|
rootKey: PrivateKey;
|
|
59
133
|
identityKey: string;
|
|
60
134
|
keyDeriver: KeyDeriver;
|
|
@@ -64,4 +138,10 @@ export interface SetupWalletOnly {
|
|
|
64
138
|
monitor: Monitor;
|
|
65
139
|
wallet: Wallet;
|
|
66
140
|
}
|
|
141
|
+
export interface SetupWalletClientArgs extends SetupWalletArgs {
|
|
142
|
+
endpointUrl?: string;
|
|
143
|
+
}
|
|
144
|
+
export interface SetupWalletClient extends SetupWallet {
|
|
145
|
+
endpointUrl: string;
|
|
146
|
+
}
|
|
67
147
|
//# sourceMappingURL=SetupClient.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SetupClient.d.ts","sourceRoot":"","sources":["../../src/SetupClient.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"SetupClient.d.ts","sourceRoot":"","sources":["../../src/S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EAAE,UAAU,CAAA;IACnB,WAAW,EAAE,MAAM,CAAA;IACnB,UAAU,EAAE,UAAU,CAAA;IACtB,KAAK,EAAE,GAAG,CAAC,KAAK,CAAA;IAChB,OAAO,EAAE,oBAAoB,CAAA;IAC7B,QAAQ,EAAE,QAAQ,CAAA;IAClB,OAAO,EAAE,OAAO,CAAA;IAChB,MAAM,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,qBAAsB,SAAQ,eAAe;IAC5D,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAED,MAAM,WAAW,iBAAkB,SAAQ,WAAW;IACpD,WAAW,EAAE,MAAM,CAAA;CACpB"}
|
package/out/src/SetupClient.js
CHANGED
|
@@ -3,16 +3,28 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.SetupClient = void 0;
|
|
4
4
|
const sdk_1 = require("@bsv/sdk");
|
|
5
5
|
const index_client_1 = require("./index.client");
|
|
6
|
-
const sdk_2 = require("./sdk");
|
|
7
6
|
/**
|
|
8
|
-
*
|
|
7
|
+
* The `SetupClient` class provides static setup functions to construct BRC-100 compatible
|
|
9
8
|
* wallets in a variety of configurations.
|
|
10
9
|
*
|
|
11
10
|
* It serves as a starting point for experimentation and customization.
|
|
12
11
|
*
|
|
12
|
+
* `SetupClient` references only browser compatible code including storage via `StorageClient`.
|
|
13
|
+
* `Setup` extends `SetupClient` adding database storage via `Knex` and `StorageKnex`.
|
|
14
|
+
*
|
|
13
15
|
*/
|
|
14
16
|
class SetupClient {
|
|
15
|
-
|
|
17
|
+
/**
|
|
18
|
+
* Creates content for .env file with some private keys, identity keys, sample API keys, and sample MySQL connection string.
|
|
19
|
+
*
|
|
20
|
+
* Two new, random private keys are generated each time, with their associated public identity keys.
|
|
21
|
+
*
|
|
22
|
+
* Loading secrets from a .env file is intended only for experimentation and getting started.
|
|
23
|
+
* Private keys should never be included directly in your source code.
|
|
24
|
+
*
|
|
25
|
+
* @publicBody
|
|
26
|
+
*/
|
|
27
|
+
static makeEnv() {
|
|
16
28
|
const testPrivKey1 = sdk_1.PrivateKey.fromRandom();
|
|
17
29
|
const testIdentityKey1 = testPrivKey1.toPublicKey().toString();
|
|
18
30
|
const testPrivKey2 = sdk_1.PrivateKey.fromRandom();
|
|
@@ -38,11 +50,22 @@ class SetupClient {
|
|
|
38
50
|
MYSQL_CONNECTION='{"port":3306,"host":"127.0.0.1","user":"root","password":"<your_password>","database":"<your_database>", "timezone": "Z"}'
|
|
39
51
|
`;
|
|
40
52
|
console.log(log);
|
|
53
|
+
return log;
|
|
41
54
|
}
|
|
55
|
+
/**
|
|
56
|
+
* Reads a .env file of the format created by `makeEnv`.
|
|
57
|
+
*
|
|
58
|
+
* Returns values for designated `chain`.
|
|
59
|
+
*
|
|
60
|
+
* Access private keys through the `devKeys` object: `devKeys[identityKey]`
|
|
61
|
+
*
|
|
62
|
+
* @param chain Which chain to use: 'test' or 'main'
|
|
63
|
+
* @returns {SetupEnv} with configuration environment secrets used by `Setup` functions.
|
|
64
|
+
*
|
|
65
|
+
* @publicBody
|
|
66
|
+
*/
|
|
42
67
|
static getEnv(chain) {
|
|
43
68
|
// Identity keys of the lead maintainer of this repo...
|
|
44
|
-
const mainTaalApiKey = (0, index_client_1.verifyTruthy)(process.env.MAIN_TAAL_API_KEY || '', `.env value for 'mainTaalApiKey' is required.`);
|
|
45
|
-
const testTaalApiKey = (0, index_client_1.verifyTruthy)(process.env.TEST_TAAL_API_KEY || '', `.env value for 'testTaalApiKey' is required.`);
|
|
46
69
|
const identityKey = chain === 'main'
|
|
47
70
|
? process.env.MY_MAIN_IDENTITY
|
|
48
71
|
: process.env.MY_TEST_IDENTITY;
|
|
@@ -51,89 +74,31 @@ class SetupClient {
|
|
|
51
74
|
: process.env.MY_TEST_IDENTITY2;
|
|
52
75
|
const DEV_KEYS = process.env.DEV_KEYS || '{}';
|
|
53
76
|
const mySQLConnection = process.env.MYSQL_CONNECTION || '{}';
|
|
77
|
+
const taalApiKey = (0, index_client_1.verifyTruthy)(chain === 'main'
|
|
78
|
+
? process.env.MAIN_TAAL_API_KEY
|
|
79
|
+
: process.env.TEST_TAAL_API_KEY, `.env value for '${chain.toUpperCase()}_TAAL_API_KEY' is required.`);
|
|
80
|
+
if (!identityKey || !identityKey2)
|
|
81
|
+
throw new index_client_1.sdk.WERR_INVALID_OPERATION('.env is not a valid SetupEnv configuration.');
|
|
54
82
|
return {
|
|
55
83
|
chain,
|
|
56
84
|
identityKey,
|
|
57
85
|
identityKey2,
|
|
58
|
-
|
|
59
|
-
testTaalApiKey,
|
|
86
|
+
taalApiKey,
|
|
60
87
|
devKeys: JSON.parse(DEV_KEYS),
|
|
61
88
|
mySQLConnection
|
|
62
89
|
};
|
|
63
90
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
const createArgs = {
|
|
78
|
-
description: `to ${address}`,
|
|
79
|
-
outputs,
|
|
80
|
-
options: {
|
|
81
|
-
noSendChange,
|
|
82
|
-
randomizeOutputs: false,
|
|
83
|
-
signAndProcess: false,
|
|
84
|
-
noSend: true
|
|
85
|
-
}
|
|
86
|
-
};
|
|
87
|
-
const cr = await wallet.createAction(createArgs);
|
|
88
|
-
noSendChange = cr.noSendChange;
|
|
89
|
-
const st = cr.signableTransaction;
|
|
90
|
-
// const tx = Transaction.fromAtomicBEEF(st.tx) // Transaction doesn't support V2 Beef yet.
|
|
91
|
-
const beef = sdk_1.Beef.fromBinary(st.tx);
|
|
92
|
-
const btx = beef.txs.slice(-1)[0];
|
|
93
|
-
const tx = beef.findAtomicTransaction(btx.txid);
|
|
94
|
-
// sign and complete
|
|
95
|
-
const signArgs = {
|
|
96
|
-
reference: st.reference,
|
|
97
|
-
spends: {},
|
|
98
|
-
options: {
|
|
99
|
-
returnTXIDOnly: true,
|
|
100
|
-
noSend: true
|
|
101
|
-
}
|
|
102
|
-
};
|
|
103
|
-
const sr = await wallet.signAction(signArgs);
|
|
104
|
-
let txid = sr.txid;
|
|
105
|
-
// Update the noSendChange txid to final signed value.
|
|
106
|
-
noSendChange = noSendChange.map(op => `${txid}.${op.split('.')[1]}`);
|
|
107
|
-
return { noSendChange, txid, cr, sr };
|
|
108
|
-
}
|
|
109
|
-
static getKeyPair(priv) {
|
|
110
|
-
if (priv === undefined)
|
|
111
|
-
priv = sdk_1.PrivateKey.fromRandom();
|
|
112
|
-
else if (typeof priv === 'string')
|
|
113
|
-
priv = new sdk_1.PrivateKey(priv, 'hex');
|
|
114
|
-
const pub = sdk_1.PublicKey.fromPrivateKey(priv);
|
|
115
|
-
const address = pub.toAddress();
|
|
116
|
-
return { privateKey: priv, publicKey: pub, address };
|
|
117
|
-
}
|
|
118
|
-
static getLockP2PKH(address) {
|
|
119
|
-
const p2pkh = new sdk_1.P2PKH();
|
|
120
|
-
const lock = p2pkh.lock(address);
|
|
121
|
-
return lock;
|
|
122
|
-
}
|
|
123
|
-
static getUnlockP2PKH(priv, satoshis) {
|
|
124
|
-
const p2pkh = new sdk_1.P2PKH();
|
|
125
|
-
const lock = SetupClient.getLockP2PKH(SetupClient.getKeyPair(priv).address);
|
|
126
|
-
// Prepare to pay with SIGHASH_ALL and without ANYONE_CAN_PAY.
|
|
127
|
-
// In otherwords:
|
|
128
|
-
// - all outputs must remain in the current order, amount and locking scripts.
|
|
129
|
-
// - all inputs must remain from the current outpoints and sequence numbers.
|
|
130
|
-
// (unlock scripts are never signed)
|
|
131
|
-
const unlock = p2pkh.unlock(priv, 'all', false, satoshis, lock);
|
|
132
|
-
return unlock;
|
|
133
|
-
}
|
|
134
|
-
static async createWalletOnly(args) {
|
|
135
|
-
args.chain || (args.chain = 'test');
|
|
136
|
-
args.rootKeyHex || (args.rootKeyHex = '1'.repeat(64));
|
|
91
|
+
/**
|
|
92
|
+
* Create a `Wallet`. Storage can optionally be provided or configured later.
|
|
93
|
+
*
|
|
94
|
+
* The following components are configured: KeyDeriver, WalletStorageManager, WalletService, WalletStorage.
|
|
95
|
+
* Optionally, PrivilegedKeyManager is also configured.
|
|
96
|
+
*
|
|
97
|
+
* @publicbody
|
|
98
|
+
*/
|
|
99
|
+
static async createWallet(args) {
|
|
100
|
+
args.chain || (args.chain = args.env.chain);
|
|
101
|
+
args.rootKeyHex || (args.rootKeyHex = args.env.devKeys[args.env.identityKey]);
|
|
137
102
|
const rootKey = sdk_1.PrivateKey.fromHex(args.rootKeyHex);
|
|
138
103
|
const identityKey = rootKey.toPublicKey().toString();
|
|
139
104
|
const keyDeriver = new sdk_1.KeyDeriver(rootKey);
|
|
@@ -141,6 +106,8 @@ class SetupClient {
|
|
|
141
106
|
const storage = new index_client_1.WalletStorageManager(identityKey, args.active, args.backups);
|
|
142
107
|
if (storage.stores.length > 0)
|
|
143
108
|
await storage.makeAvailable();
|
|
109
|
+
const serviceOptions = index_client_1.Services.createDefaultOptions(chain);
|
|
110
|
+
serviceOptions.taalApiKey = args.env.taalApiKey;
|
|
144
111
|
const services = new index_client_1.Services(args.chain);
|
|
145
112
|
const monopts = index_client_1.Monitor.createDefaultWalletMonitorOptions(chain, storage, services);
|
|
146
113
|
const monitor = new index_client_1.Monitor(monopts);
|
|
@@ -148,7 +115,7 @@ class SetupClient {
|
|
|
148
115
|
let privilegedKeyManager = undefined;
|
|
149
116
|
if (args.privKeyHex) {
|
|
150
117
|
const privKey = sdk_1.PrivateKey.fromString(args.privKeyHex);
|
|
151
|
-
privilegedKeyManager = new
|
|
118
|
+
privilegedKeyManager = new index_client_1.sdk.PrivilegedKeyManager(async () => privKey);
|
|
152
119
|
}
|
|
153
120
|
const wallet = new index_client_1.Wallet({
|
|
154
121
|
chain,
|
|
@@ -170,18 +137,100 @@ class SetupClient {
|
|
|
170
137
|
};
|
|
171
138
|
return r;
|
|
172
139
|
}
|
|
140
|
+
/**
|
|
141
|
+
* @publicBody
|
|
142
|
+
*/
|
|
173
143
|
static async createWalletWithStorageClient(args) {
|
|
174
|
-
|
|
144
|
+
const wo = await SetupClient.createWallet(args);
|
|
145
|
+
if (wo.chain === 'main')
|
|
175
146
|
throw new index_client_1.sdk.WERR_INVALID_PARAMETER('chain', `'test' for now, 'main' is not yet supported.`);
|
|
176
|
-
const
|
|
177
|
-
|
|
178
|
-
rootKeyHex: args.rootKeyHex
|
|
179
|
-
});
|
|
180
|
-
args.endpointUrl || (args.endpointUrl = 'https://staging-dojo.babbage.systems');
|
|
181
|
-
const client = new index_client_1.StorageClient(wo.wallet, args.endpointUrl);
|
|
147
|
+
const endpointUrl = args.endpointUrl || 'https://staging-dojo.babbage.systems';
|
|
148
|
+
const client = new index_client_1.StorageClient(wo.wallet, endpointUrl);
|
|
182
149
|
await wo.storage.addWalletStorageProvider(client);
|
|
183
150
|
await wo.storage.makeAvailable();
|
|
184
|
-
return
|
|
151
|
+
return {
|
|
152
|
+
...wo,
|
|
153
|
+
endpointUrl
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* @publicBody
|
|
158
|
+
*/
|
|
159
|
+
static getKeyPair(priv) {
|
|
160
|
+
if (priv === undefined)
|
|
161
|
+
priv = sdk_1.PrivateKey.fromRandom();
|
|
162
|
+
else if (typeof priv === 'string')
|
|
163
|
+
priv = new sdk_1.PrivateKey(priv, 'hex');
|
|
164
|
+
const pub = sdk_1.PublicKey.fromPrivateKey(priv);
|
|
165
|
+
const address = pub.toAddress();
|
|
166
|
+
return { privateKey: priv, publicKey: pub, address };
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* @publicBody
|
|
170
|
+
*/
|
|
171
|
+
static getLockP2PKH(address) {
|
|
172
|
+
const p2pkh = new sdk_1.P2PKH();
|
|
173
|
+
const lock = p2pkh.lock(address);
|
|
174
|
+
return lock;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* @publicBody
|
|
178
|
+
*/
|
|
179
|
+
static getUnlockP2PKH(priv, satoshis) {
|
|
180
|
+
const p2pkh = new sdk_1.P2PKH();
|
|
181
|
+
const lock = SetupClient.getLockP2PKH(SetupClient.getKeyPair(priv).address);
|
|
182
|
+
// Prepare to pay with SIGHASH_ALL and without ANYONE_CAN_PAY.
|
|
183
|
+
// In otherwords:
|
|
184
|
+
// - all outputs must remain in the current order, amount and locking scripts.
|
|
185
|
+
// - all inputs must remain from the current outpoints and sequence numbers.
|
|
186
|
+
// (unlock scripts are never signed)
|
|
187
|
+
const unlock = p2pkh.unlock(priv, 'all', false, satoshis, lock);
|
|
188
|
+
return unlock;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* @publicBody
|
|
192
|
+
*/
|
|
193
|
+
static createP2PKHOutputs(outputs) {
|
|
194
|
+
const os = [];
|
|
195
|
+
const count = outputs.length;
|
|
196
|
+
for (let i = 0; i < count; i++) {
|
|
197
|
+
const o = outputs[i];
|
|
198
|
+
os.push({
|
|
199
|
+
basket: o.basket,
|
|
200
|
+
tags: o.tags,
|
|
201
|
+
satoshis: o.satoshis,
|
|
202
|
+
lockingScript: SetupClient.getLockP2PKH(o.address).toHex(),
|
|
203
|
+
outputDescription: o.outputDescription || `p2pkh ${i}`
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
return os;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* @publicBody
|
|
210
|
+
*/
|
|
211
|
+
static async createP2PKHOutputsAction(wallet, outputs, options) {
|
|
212
|
+
const os = SetupClient.createP2PKHOutputs(outputs);
|
|
213
|
+
const createArgs = {
|
|
214
|
+
description: `createP2PKHOutputs`,
|
|
215
|
+
outputs: os,
|
|
216
|
+
options: {
|
|
217
|
+
...options,
|
|
218
|
+
// Don't randomize so we can simplify outpoint creation
|
|
219
|
+
randomizeOutputs: false
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
const cr = await wallet.createAction(createArgs);
|
|
223
|
+
let outpoints;
|
|
224
|
+
if (cr.txid) {
|
|
225
|
+
outpoints = os.map((o, i) => `${cr.txid}.${i}`);
|
|
226
|
+
}
|
|
227
|
+
return { cr, outpoints };
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* @publicBody
|
|
231
|
+
*/
|
|
232
|
+
static async fundWalletFromP2PKHOutpoints(wallet, outpoints, p2pkhKey, inputBEEF) {
|
|
233
|
+
// TODO
|
|
185
234
|
}
|
|
186
235
|
}
|
|
187
236
|
exports.SetupClient = SetupClient;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SetupClient.js","sourceRoot":"","sources":["../../src/SetupClient.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"SetupClient.js","sourceRoot":"","sources":["../../src/SetupClient.ts"],"names":[],"mappings":";;;AAAA,kCAgBiB;AACjB,iDAQuB;AAEvB;;;;;;;;;GASG;AACH,MAAsB,WAAW;IAC/B;;;;;;;;;OASG;IACH,MAAM,CAAC,OAAO;QACZ,MAAM,YAAY,GAAG,gBAAU,CAAC,UAAU,EAAE,CAAA;QAC5C,MAAM,gBAAgB,GAAG,YAAY,CAAC,WAAW,EAAE,CAAC,QAAQ,EAAE,CAAA;QAC9D,MAAM,YAAY,GAAG,gBAAU,CAAC,UAAU,EAAE,CAAA;QAC5C,MAAM,gBAAgB,GAAG,YAAY,CAAC,WAAW,EAAE,CAAC,QAAQ,EAAE,CAAA;QAC9D,MAAM,YAAY,GAAG,gBAAU,CAAC,UAAU,EAAE,CAAA;QAC5C,MAAM,gBAAgB,GAAG,YAAY,CAAC,WAAW,EAAE,CAAC,QAAQ,EAAE,CAAA;QAC9D,MAAM,YAAY,GAAG,gBAAU,CAAC,UAAU,EAAE,CAAA;QAC5C,MAAM,gBAAgB,GAAG,YAAY,CAAC,WAAW,EAAE,CAAC,QAAQ,EAAE,CAAA;QAE9D,MAAM,GAAG,GAAG;;;;0BAIU,gBAAgB;2BACf,gBAAgB;0BACjB,gBAAgB;2BACf,gBAAgB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A8RC"}
|
package/out/src/Wallet.d.ts
CHANGED
|
@@ -15,6 +15,16 @@ export declare class Wallet implements WalletInterface, ProtoWallet {
|
|
|
15
15
|
services?: sdk.WalletServices;
|
|
16
16
|
monitor?: Monitor;
|
|
17
17
|
identityKey: string;
|
|
18
|
+
/**
|
|
19
|
+
* The wallet creates a `BeefParty` when it is created.
|
|
20
|
+
* All the Beefs that pass through the wallet are merged into this beef.
|
|
21
|
+
* Thus what it contains at any time is the union of all transactions and proof data processed.
|
|
22
|
+
* The class `BeefParty` derives from `Beef`, adding the ability to track the source of merged data.
|
|
23
|
+
*
|
|
24
|
+
* This allows it to generate beefs to send to a particular “party” (storage or the user)
|
|
25
|
+
* that includes “txid only proofs” for transactions they already know about.
|
|
26
|
+
* Over time, this allows an active wallet to drastically reduce the amount of data transmitted.
|
|
27
|
+
*/
|
|
18
28
|
beef: BeefParty;
|
|
19
29
|
trustSelf?: TrustSelf;
|
|
20
30
|
userParty: string;
|