@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/docs/README.md
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
The documentation is split into various pages, each covering a set of related functionality. The pages are as follows:
|
|
4
4
|
|
|
5
5
|
- [Getting Started](#getting-started) -
|
|
6
|
+
- [Setup](./setup.md) —
|
|
6
7
|
- [Wallet](./wallet.md) —
|
|
7
8
|
- [Client](./client.md) —
|
|
8
9
|
- [Storage](./storage.md) —
|
package/docs/client.md
CHANGED
|
@@ -6,47 +6,48 @@ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](
|
|
|
6
6
|
|
|
7
7
|
| | | |
|
|
8
8
|
| --- | --- | --- |
|
|
9
|
-
| [ArcMinerGetTxData](#interface-arcminergettxdata) | [
|
|
10
|
-
| [ArcMinerPostBeefDataApi](#interface-arcminerpostbeefdataapi) | [
|
|
11
|
-
| [ArcMinerPostTxsData](#interface-arcminerposttxsdata) | [
|
|
12
|
-
| [ArcServiceConfig](#interface-arcserviceconfig) | [
|
|
13
|
-
| [AuthId](#interface-authid) | [
|
|
14
|
-
| [BaseBlockHeader](#interface-baseblockheader) | [
|
|
15
|
-
| [BlockHeader](#interface-blockheader) | [
|
|
16
|
-
| [BsvExchangeRate](#interface-bsvexchangerate) | [
|
|
17
|
-
| [CertOpsWallet](#interface-certopswallet) | [
|
|
18
|
-
| [CommitNewTxResults](#interface-commitnewtxresults) | [
|
|
19
|
-
| [EntityTimeStamp](#interface-entitytimestamp) | [
|
|
20
|
-
| [ExchangeRatesIoApi](#interface-exchangeratesioapi) | [
|
|
21
|
-
| [FiatExchangeRates](#interface-fiatexchangerates) | [
|
|
22
|
-
| [FindCertificateFieldsArgs](#interface-findcertificatefieldsargs) | [
|
|
23
|
-
| [FindCertificatesArgs](#interface-findcertificatesargs) | [
|
|
24
|
-
| [FindCommissionsArgs](#interface-findcommissionsargs) | [
|
|
25
|
-
| [FindForUserSincePagedArgs](#interface-findforusersincepagedargs) | [
|
|
26
|
-
| [FindMonitorEventsArgs](#interface-findmonitoreventsargs) | [
|
|
27
|
-
| [FindOutputBasketsArgs](#interface-findoutputbasketsargs) | [
|
|
28
|
-
| [FindOutputTagMapsArgs](#interface-findoutputtagmapsargs) | [
|
|
29
|
-
| [FindOutputTagsArgs](#interface-findoutputtagsargs) | [
|
|
30
|
-
| [FindOutputsArgs](#interface-findoutputsargs) | [
|
|
31
|
-
| [FindPartialSincePagedArgs](#interface-findpartialsincepagedargs) | [
|
|
32
|
-
| [FindProvenTxReqsArgs](#interface-findproventxreqsargs) | [
|
|
33
|
-
| [FindProvenTxsArgs](#interface-findproventxsargs) | [
|
|
34
|
-
| [FindSincePagedArgs](#interface-findsincepagedargs) | [
|
|
35
|
-
| [FindSyncStatesArgs](#interface-findsyncstatesargs) | [
|
|
36
|
-
| [FindTransactionsArgs](#interface-findtransactionsargs) | [
|
|
37
|
-
| [FindTxLabelMapsArgs](#interface-findtxlabelmapsargs) | [
|
|
38
|
-
| [FindTxLabelsArgs](#interface-findtxlabelsargs) | [
|
|
39
|
-
| [FindUsersArgs](#interface-findusersargs) | [
|
|
40
|
-
| [GenerateChangeSdkChangeInput](#interface-generatechangesdkchangeinput) | [
|
|
41
|
-
| [GenerateChangeSdkChangeOutput](#interface-generatechangesdkchangeoutput) | [
|
|
42
|
-
| [GenerateChangeSdkInput](#interface-generatechangesdkinput) | [
|
|
43
|
-
| [GenerateChangeSdkOutput](#interface-generatechangesdkoutput) | [
|
|
44
|
-
| [GenerateChangeSdkParams](#interface-generatechangesdkparams) | [
|
|
45
|
-
| [GenerateChangeSdkResult](#interface-generatechangesdkresult) | [
|
|
46
|
-
| [GenerateChangeSdkStorageChange](#interface-generatechangesdkstoragechange) | [
|
|
47
|
-
| [GetMerklePathResult](#interface-getmerklepathresult) | [
|
|
48
|
-
| [GetRawTxResult](#interface-getrawtxresult) | [
|
|
49
|
-
| [GetReqsAndBeefDetail](#interface-getreqsandbeefdetail) | [
|
|
9
|
+
| [ArcMinerGetTxData](#interface-arcminergettxdata) | [GetUtxoStatusDetails](#interface-getutxostatusdetails) | [SyncChunk](#interface-syncchunk) |
|
|
10
|
+
| [ArcMinerPostBeefDataApi](#interface-arcminerpostbeefdataapi) | [GetUtxoStatusResult](#interface-getutxostatusresult) | [TaskPurgeParams](#interface-taskpurgeparams) |
|
|
11
|
+
| [ArcMinerPostTxsData](#interface-arcminerposttxsdata) | [KeyPair](#interface-keypair) | [TrxToken](#interface-trxtoken) |
|
|
12
|
+
| [ArcServiceConfig](#interface-arcserviceconfig) | [MonitorOptions](#interface-monitoroptions) | [TscMerkleProofApi](#interface-tscmerkleproofapi) |
|
|
13
|
+
| [AuthId](#interface-authid) | [OutPoint](#interface-outpoint) | [TxScriptOffsets](#interface-txscriptoffsets) |
|
|
14
|
+
| [BaseBlockHeader](#interface-baseblockheader) | [Paged](#interface-paged) | [UpdateProvenTxReqWithNewProvenTxArgs](#interface-updateproventxreqwithnewproventxargs) |
|
|
15
|
+
| [BlockHeader](#interface-blockheader) | [PendingSignAction](#interface-pendingsignaction) | [UpdateProvenTxReqWithNewProvenTxResult](#interface-updateproventxreqwithnewproventxresult) |
|
|
16
|
+
| [BsvExchangeRate](#interface-bsvexchangerate) | [PendingStorageInput](#interface-pendingstorageinput) | [ValidAbortActionArgs](#interface-validabortactionargs) |
|
|
17
|
+
| [CertOpsWallet](#interface-certopswallet) | [PostBeefResult](#interface-postbeefresult) | [ValidAcquireCertificateArgs](#interface-validacquirecertificateargs) |
|
|
18
|
+
| [CommitNewTxResults](#interface-commitnewtxresults) | [PostBeefResultForTxidApi](#interface-postbeefresultfortxidapi) | [ValidAcquireDirectCertificateArgs](#interface-validacquiredirectcertificateargs) |
|
|
19
|
+
| [EntityTimeStamp](#interface-entitytimestamp) | [PostReqsToNetworkDetails](#interface-postreqstonetworkdetails) | [ValidAcquireIssuanceCertificateArgs](#interface-validacquireissuancecertificateargs) |
|
|
20
|
+
| [ExchangeRatesIoApi](#interface-exchangeratesioapi) | [PostReqsToNetworkResult](#interface-postreqstonetworkresult) | [ValidBasketInsertion](#interface-validbasketinsertion) |
|
|
21
|
+
| [FiatExchangeRates](#interface-fiatexchangerates) | [PostTxResultForTxid](#interface-posttxresultfortxid) | [ValidCreateActionArgs](#interface-validcreateactionargs) |
|
|
22
|
+
| [FindCertificateFieldsArgs](#interface-findcertificatefieldsargs) | [PostTxsResult](#interface-posttxsresult) | [ValidCreateActionInput](#interface-validcreateactioninput) |
|
|
23
|
+
| [FindCertificatesArgs](#interface-findcertificatesargs) | [ProcessSyncChunkResult](#interface-processsyncchunkresult) | [ValidCreateActionOptions](#interface-validcreateactionoptions) |
|
|
24
|
+
| [FindCommissionsArgs](#interface-findcommissionsargs) | [ProvenOrRawTx](#interface-provenorrawtx) | [ValidCreateActionOutput](#interface-validcreateactionoutput) |
|
|
25
|
+
| [FindForUserSincePagedArgs](#interface-findforusersincepagedargs) | [PurgeParams](#interface-purgeparams) | [ValidDiscoverByAttributesArgs](#interface-validdiscoverbyattributesargs) |
|
|
26
|
+
| [FindMonitorEventsArgs](#interface-findmonitoreventsargs) | [PurgeResults](#interface-purgeresults) | [ValidDiscoverByIdentityKeyArgs](#interface-validdiscoverbyidentitykeyargs) |
|
|
27
|
+
| [FindOutputBasketsArgs](#interface-findoutputbasketsargs) | [RequestSyncChunkArgs](#interface-requestsyncchunkargs) | [ValidInternalizeActionArgs](#interface-validinternalizeactionargs) |
|
|
28
|
+
| [FindOutputTagMapsArgs](#interface-findoutputtagmapsargs) | [ScriptTemplateParamsSABPPP](#interface-scripttemplateparamssabppp) | [ValidInternalizeOutput](#interface-validinternalizeoutput) |
|
|
29
|
+
| [FindOutputTagsArgs](#interface-findoutputtagsargs) | [ScriptTemplateUnlock](#interface-scripttemplateunlock) | [ValidListActionsArgs](#interface-validlistactionsargs) |
|
|
30
|
+
| [FindOutputsArgs](#interface-findoutputsargs) | [SetupEnv](#interface-setupenv) | [ValidListCertificatesArgs](#interface-validlistcertificatesargs) |
|
|
31
|
+
| [FindPartialSincePagedArgs](#interface-findpartialsincepagedargs) | [SetupWallet](#interface-setupwallet) | [ValidListOutputsArgs](#interface-validlistoutputsargs) |
|
|
32
|
+
| [FindProvenTxReqsArgs](#interface-findproventxreqsargs) | [SetupWalletArgs](#interface-setupwalletargs) | [ValidProcessActionArgs](#interface-validprocessactionargs) |
|
|
33
|
+
| [FindProvenTxsArgs](#interface-findproventxsargs) | [SetupWalletClient](#interface-setupwalletclient) | [ValidProcessActionOptions](#interface-validprocessactionoptions) |
|
|
34
|
+
| [FindSincePagedArgs](#interface-findsincepagedargs) | [SetupWalletClientArgs](#interface-setupwalletclientargs) | [ValidProveCertificateArgs](#interface-validprovecertificateargs) |
|
|
35
|
+
| [FindSyncStatesArgs](#interface-findsyncstatesargs) | [StorageCreateActionResult](#interface-storagecreateactionresult) | [ValidRelinquishCertificateArgs](#interface-validrelinquishcertificateargs) |
|
|
36
|
+
| [FindTransactionsArgs](#interface-findtransactionsargs) | [StorageCreateTransactionSdkInput](#interface-storagecreatetransactionsdkinput) | [ValidRelinquishOutputArgs](#interface-validrelinquishoutputargs) |
|
|
37
|
+
| [FindTxLabelMapsArgs](#interface-findtxlabelmapsargs) | [StorageCreateTransactionSdkOutput](#interface-storagecreatetransactionsdkoutput) | [ValidSignActionArgs](#interface-validsignactionargs) |
|
|
38
|
+
| [FindTxLabelsArgs](#interface-findtxlabelsargs) | [StorageFeeModel](#interface-storagefeemodel) | [ValidSignActionOptions](#interface-validsignactionoptions) |
|
|
39
|
+
| [FindUsersArgs](#interface-findusersargs) | [StorageGetBeefOptions](#interface-storagegetbeefoptions) | [ValidWalletPayment](#interface-validwalletpayment) |
|
|
40
|
+
| [GenerateChangeSdkChangeInput](#interface-generatechangesdkchangeinput) | [StorageIdentity](#interface-storageidentity) | [ValidWalletSignerArgs](#interface-validwalletsignerargs) |
|
|
41
|
+
| [GenerateChangeSdkChangeOutput](#interface-generatechangesdkchangeoutput) | [StorageInternalizeActionResult](#interface-storageinternalizeactionresult) | [WalletArgs](#interface-walletargs) |
|
|
42
|
+
| [GenerateChangeSdkInput](#interface-generatechangesdkinput) | [StorageProcessActionArgs](#interface-storageprocessactionargs) | [WalletServices](#interface-walletservices) |
|
|
43
|
+
| [GenerateChangeSdkOutput](#interface-generatechangesdkoutput) | [StorageProcessActionResults](#interface-storageprocessactionresults) | [WalletServicesOptions](#interface-walletservicesoptions) |
|
|
44
|
+
| [GenerateChangeSdkParams](#interface-generatechangesdkparams) | [StorageProvenOrReq](#interface-storageprovenorreq) | [WalletSigner](#interface-walletsigner) |
|
|
45
|
+
| [GenerateChangeSdkResult](#interface-generatechangesdkresult) | [StorageProviderOptions](#interface-storageprovideroptions) | [WalletStorage](#interface-walletstorage) |
|
|
46
|
+
| [GenerateChangeSdkStorageChange](#interface-generatechangesdkstoragechange) | [StorageReaderOptions](#interface-storagereaderoptions) | [WalletStorageProvider](#interface-walletstorageprovider) |
|
|
47
|
+
| [GetMerklePathResult](#interface-getmerklepathresult) | [StorageReaderWriterOptions](#interface-storagereaderwriteroptions) | [WalletStorageReader](#interface-walletstoragereader) |
|
|
48
|
+
| [GetRawTxResult](#interface-getrawtxresult) | [StorageSyncReader](#interface-storagesyncreader) | [WalletStorageSync](#interface-walletstoragesync) |
|
|
49
|
+
| [GetReqsAndBeefDetail](#interface-getreqsandbeefdetail) | [StorageSyncReaderOptions](#interface-storagesyncreaderoptions) | [WalletStorageWriter](#interface-walletstoragewriter) |
|
|
50
|
+
| [GetReqsAndBeefResult](#interface-getreqsandbeefresult) | [StorageSyncReaderWriter](#interface-storagesyncreaderwriter) | [XValidCreateActionOutput](#interface-xvalidcreateactionoutput) |
|
|
50
51
|
|
|
51
52
|
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
|
|
52
53
|
|
|
@@ -1514,10 +1515,40 @@ export interface ScriptTemplateParamsSABPPP {
|
|
|
1514
1515
|
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
|
|
1515
1516
|
|
|
1516
1517
|
---
|
|
1517
|
-
### Interface:
|
|
1518
|
+
### Interface: ScriptTemplateUnlock
|
|
1518
1519
|
|
|
1519
1520
|
```ts
|
|
1520
|
-
export interface
|
|
1521
|
+
export interface ScriptTemplateUnlock {
|
|
1522
|
+
sign: (tx: Transaction, inputIndex: number) => Promise<UnlockingScript>;
|
|
1523
|
+
estimateLength: (tx: Transaction, inputIndex: number) => Promise<number>;
|
|
1524
|
+
}
|
|
1525
|
+
```
|
|
1526
|
+
|
|
1527
|
+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
|
|
1528
|
+
|
|
1529
|
+
---
|
|
1530
|
+
### Interface: SetupEnv
|
|
1531
|
+
|
|
1532
|
+
```ts
|
|
1533
|
+
export interface SetupEnv {
|
|
1534
|
+
chain: sdk.Chain;
|
|
1535
|
+
identityKey: string;
|
|
1536
|
+
identityKey2: string;
|
|
1537
|
+
taalApiKey: string;
|
|
1538
|
+
devKeys: Record<string, string>;
|
|
1539
|
+
mySQLConnection: string;
|
|
1540
|
+
}
|
|
1541
|
+
```
|
|
1542
|
+
|
|
1543
|
+
See also: [Chain](#type-chain)
|
|
1544
|
+
|
|
1545
|
+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
|
|
1546
|
+
|
|
1547
|
+
---
|
|
1548
|
+
### Interface: SetupWallet
|
|
1549
|
+
|
|
1550
|
+
```ts
|
|
1551
|
+
export interface SetupWallet {
|
|
1521
1552
|
rootKey: PrivateKey;
|
|
1522
1553
|
identityKey: string;
|
|
1523
1554
|
keyDeriver: KeyDeriver;
|
|
@@ -1533,6 +1564,52 @@ See also: [Chain](#type-chain), [Monitor](#class-monitor), [Services](#class-ser
|
|
|
1533
1564
|
|
|
1534
1565
|
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
|
|
1535
1566
|
|
|
1567
|
+
---
|
|
1568
|
+
### Interface: SetupWalletArgs
|
|
1569
|
+
|
|
1570
|
+
Arguments used to construct a `Wallet`
|
|
1571
|
+
|
|
1572
|
+
```ts
|
|
1573
|
+
export interface SetupWalletArgs {
|
|
1574
|
+
env: SetupEnv;
|
|
1575
|
+
chain?: sdk.Chain;
|
|
1576
|
+
rootKeyHex?: string;
|
|
1577
|
+
privKeyHex?: string;
|
|
1578
|
+
active?: sdk.WalletStorageProvider;
|
|
1579
|
+
backups?: sdk.WalletStorageProvider[];
|
|
1580
|
+
}
|
|
1581
|
+
```
|
|
1582
|
+
|
|
1583
|
+
See also: [Chain](#type-chain), [SetupEnv](#interface-setupenv), [WalletStorageProvider](#interface-walletstorageprovider)
|
|
1584
|
+
|
|
1585
|
+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
|
|
1586
|
+
|
|
1587
|
+
---
|
|
1588
|
+
### Interface: SetupWalletClient
|
|
1589
|
+
|
|
1590
|
+
```ts
|
|
1591
|
+
export interface SetupWalletClient extends SetupWallet {
|
|
1592
|
+
endpointUrl: string;
|
|
1593
|
+
}
|
|
1594
|
+
```
|
|
1595
|
+
|
|
1596
|
+
See also: [SetupWallet](#interface-setupwallet)
|
|
1597
|
+
|
|
1598
|
+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
|
|
1599
|
+
|
|
1600
|
+
---
|
|
1601
|
+
### Interface: SetupWalletClientArgs
|
|
1602
|
+
|
|
1603
|
+
```ts
|
|
1604
|
+
export interface SetupWalletClientArgs extends SetupWalletArgs {
|
|
1605
|
+
endpointUrl?: string;
|
|
1606
|
+
}
|
|
1607
|
+
```
|
|
1608
|
+
|
|
1609
|
+
See also: [SetupWalletArgs](#interface-setupwalletargs)
|
|
1610
|
+
|
|
1611
|
+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
|
|
1612
|
+
|
|
1536
1613
|
---
|
|
1537
1614
|
### Interface: StorageCreateActionResult
|
|
1538
1615
|
|
|
@@ -3399,6 +3476,9 @@ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](
|
|
|
3399
3476
|
---
|
|
3400
3477
|
### Class: ScriptTemplateSABPPP
|
|
3401
3478
|
|
|
3479
|
+
Simple Authenticated BSV P2PKH Payment Protocol
|
|
3480
|
+
https://brc.dev/29
|
|
3481
|
+
|
|
3402
3482
|
```ts
|
|
3403
3483
|
export class ScriptTemplateSABPPP implements ScriptTemplate {
|
|
3404
3484
|
p2pkh: P2PKH;
|
|
@@ -3526,14 +3606,17 @@ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](
|
|
|
3526
3606
|
---
|
|
3527
3607
|
### Class: SetupClient
|
|
3528
3608
|
|
|
3529
|
-
|
|
3609
|
+
The `SetupClient` class provides static setup functions to construct BRC-100 compatible
|
|
3530
3610
|
wallets in a variety of configurations.
|
|
3531
3611
|
|
|
3532
3612
|
It serves as a starting point for experimentation and customization.
|
|
3533
3613
|
|
|
3614
|
+
`SetupClient` references only browser compatible code including storage via `StorageClient`.
|
|
3615
|
+
`Setup` extends `SetupClient` adding database storage via `Knex` and `StorageKnex`.
|
|
3616
|
+
|
|
3534
3617
|
```ts
|
|
3535
3618
|
export abstract class SetupClient {
|
|
3536
|
-
static makeEnv(
|
|
3619
|
+
static makeEnv(): string {
|
|
3537
3620
|
const testPrivKey1 = PrivateKey.fromRandom();
|
|
3538
3621
|
const testIdentityKey1 = testPrivKey1.toPublicKey().toString();
|
|
3539
3622
|
const testPrivKey2 = PrivateKey.fromRandom();
|
|
@@ -3559,39 +3642,169 @@ export abstract class SetupClient {
|
|
|
3559
3642
|
MYSQL_CONNECTION='{"port":3306,"host":"127.0.0.1","user":"root","password":"<your_password>","database":"<your_database>", "timezone": "Z"}'
|
|
3560
3643
|
`;
|
|
3561
3644
|
console.log(log);
|
|
3645
|
+
return log;
|
|
3562
3646
|
}
|
|
3563
|
-
static getEnv(chain: sdk.Chain)
|
|
3564
|
-
static async
|
|
3565
|
-
|
|
3566
|
-
|
|
3567
|
-
|
|
3568
|
-
|
|
3569
|
-
|
|
3570
|
-
|
|
3571
|
-
|
|
3572
|
-
|
|
3573
|
-
|
|
3574
|
-
|
|
3575
|
-
|
|
3647
|
+
static getEnv(chain: sdk.Chain): SetupEnv
|
|
3648
|
+
static async createWallet(args: SetupWalletArgs): Promise<SetupWallet> {
|
|
3649
|
+
args.chain ||= args.env.chain;
|
|
3650
|
+
args.rootKeyHex ||= args.env.devKeys[args.env.identityKey];
|
|
3651
|
+
const rootKey = PrivateKey.fromHex(args.rootKeyHex);
|
|
3652
|
+
const identityKey = rootKey.toPublicKey().toString();
|
|
3653
|
+
const keyDeriver = new KeyDeriver(rootKey);
|
|
3654
|
+
const chain = args.chain;
|
|
3655
|
+
const storage = new WalletStorageManager(identityKey, args.active, args.backups);
|
|
3656
|
+
if (storage.stores.length > 0)
|
|
3657
|
+
await storage.makeAvailable();
|
|
3658
|
+
const serviceOptions = Services.createDefaultOptions(chain);
|
|
3659
|
+
serviceOptions.taalApiKey = args.env.taalApiKey;
|
|
3660
|
+
const services = new Services(args.chain);
|
|
3661
|
+
const monopts = Monitor.createDefaultWalletMonitorOptions(chain, storage, services);
|
|
3662
|
+
const monitor = new Monitor(monopts);
|
|
3663
|
+
monitor.addDefaultTasks();
|
|
3664
|
+
let privilegedKeyManager: sdk.PrivilegedKeyManager | undefined = undefined;
|
|
3665
|
+
if (args.privKeyHex) {
|
|
3666
|
+
const privKey = PrivateKey.fromString(args.privKeyHex);
|
|
3667
|
+
privilegedKeyManager = new sdk.PrivilegedKeyManager(async () => privKey);
|
|
3668
|
+
}
|
|
3669
|
+
const wallet = new Wallet({
|
|
3670
|
+
chain,
|
|
3671
|
+
keyDeriver,
|
|
3672
|
+
storage,
|
|
3673
|
+
services,
|
|
3674
|
+
monitor,
|
|
3675
|
+
privilegedKeyManager
|
|
3676
|
+
});
|
|
3677
|
+
const r: SetupWallet = {
|
|
3678
|
+
rootKey,
|
|
3679
|
+
identityKey,
|
|
3680
|
+
keyDeriver,
|
|
3681
|
+
chain,
|
|
3682
|
+
storage,
|
|
3683
|
+
services,
|
|
3684
|
+
monitor,
|
|
3685
|
+
wallet
|
|
3686
|
+
};
|
|
3687
|
+
return r;
|
|
3688
|
+
}
|
|
3689
|
+
static async createWalletWithStorageClient(args: SetupWalletClientArgs): Promise<SetupWalletClient>
|
|
3576
3690
|
static getKeyPair(priv?: string | PrivateKey): KeyPairAddress
|
|
3577
3691
|
static getLockP2PKH(address: string)
|
|
3578
|
-
static getUnlockP2PKH(priv: PrivateKey, satoshis: number)
|
|
3579
|
-
static
|
|
3580
|
-
|
|
3581
|
-
|
|
3582
|
-
|
|
3583
|
-
|
|
3584
|
-
|
|
3585
|
-
}):
|
|
3586
|
-
static async
|
|
3587
|
-
|
|
3588
|
-
|
|
3589
|
-
|
|
3590
|
-
|
|
3692
|
+
static getUnlockP2PKH(priv: PrivateKey, satoshis: number): sdk.ScriptTemplateUnlock
|
|
3693
|
+
static createP2PKHOutputs(outputs: {
|
|
3694
|
+
address: string;
|
|
3695
|
+
satoshis: number;
|
|
3696
|
+
outputDescription?: string;
|
|
3697
|
+
basket?: string;
|
|
3698
|
+
tags?: string[];
|
|
3699
|
+
}[]): CreateActionOutput[]
|
|
3700
|
+
static async createP2PKHOutputsAction(wallet: WalletInterface, outputs: {
|
|
3701
|
+
address: string;
|
|
3702
|
+
satoshis: number;
|
|
3703
|
+
outputDescription?: string;
|
|
3704
|
+
basket?: string;
|
|
3705
|
+
tags?: string[];
|
|
3706
|
+
}[], options?: CreateActionOptions): Promise<{
|
|
3707
|
+
cr: CreateActionResult;
|
|
3708
|
+
outpoints: string[] | undefined;
|
|
3709
|
+
}>
|
|
3710
|
+
static async fundWalletFromP2PKHOutpoints(wallet: WalletInterface, outpoints: string[], p2pkhKey: KeyPairAddress, inputBEEF?: BEEF)
|
|
3711
|
+
}
|
|
3712
|
+
```
|
|
3713
|
+
|
|
3714
|
+
See also: [Chain](#type-chain), [KeyPairAddress](#type-keypairaddress), [Monitor](#class-monitor), [PrivilegedKeyManager](#class-privilegedkeymanager), [ScriptTemplateUnlock](#interface-scripttemplateunlock), [Services](#class-services), [SetupEnv](#interface-setupenv), [SetupWallet](#interface-setupwallet), [SetupWalletArgs](#interface-setupwalletargs), [SetupWalletClient](#interface-setupwalletclient), [SetupWalletClientArgs](#interface-setupwalletclientargs), [Wallet](#class-wallet), [WalletStorageManager](#class-walletstoragemanager)
|
|
3715
|
+
|
|
3716
|
+
<details>
|
|
3717
|
+
|
|
3718
|
+
<summary>Class SetupClient Details</summary>
|
|
3719
|
+
|
|
3720
|
+
#### Method createWallet
|
|
3721
|
+
|
|
3722
|
+
Create a `Wallet`. Storage can optionally be provided or configured later.
|
|
3723
|
+
|
|
3724
|
+
The following components are configured: KeyDeriver, WalletStorageManager, WalletService, WalletStorage.
|
|
3725
|
+
Optionally, PrivilegedKeyManager is also configured.
|
|
3726
|
+
|
|
3727
|
+
```ts
|
|
3728
|
+
static async createWallet(args: SetupWalletArgs): Promise<SetupWallet> {
|
|
3729
|
+
args.chain ||= args.env.chain;
|
|
3730
|
+
args.rootKeyHex ||= args.env.devKeys[args.env.identityKey];
|
|
3731
|
+
const rootKey = PrivateKey.fromHex(args.rootKeyHex);
|
|
3732
|
+
const identityKey = rootKey.toPublicKey().toString();
|
|
3733
|
+
const keyDeriver = new KeyDeriver(rootKey);
|
|
3734
|
+
const chain = args.chain;
|
|
3735
|
+
const storage = new WalletStorageManager(identityKey, args.active, args.backups);
|
|
3736
|
+
if (storage.stores.length > 0)
|
|
3737
|
+
await storage.makeAvailable();
|
|
3738
|
+
const serviceOptions = Services.createDefaultOptions(chain);
|
|
3739
|
+
serviceOptions.taalApiKey = args.env.taalApiKey;
|
|
3740
|
+
const services = new Services(args.chain);
|
|
3741
|
+
const monopts = Monitor.createDefaultWalletMonitorOptions(chain, storage, services);
|
|
3742
|
+
const monitor = new Monitor(monopts);
|
|
3743
|
+
monitor.addDefaultTasks();
|
|
3744
|
+
let privilegedKeyManager: sdk.PrivilegedKeyManager | undefined = undefined;
|
|
3745
|
+
if (args.privKeyHex) {
|
|
3746
|
+
const privKey = PrivateKey.fromString(args.privKeyHex);
|
|
3747
|
+
privilegedKeyManager = new sdk.PrivilegedKeyManager(async () => privKey);
|
|
3748
|
+
}
|
|
3749
|
+
const wallet = new Wallet({
|
|
3750
|
+
chain,
|
|
3751
|
+
keyDeriver,
|
|
3752
|
+
storage,
|
|
3753
|
+
services,
|
|
3754
|
+
monitor,
|
|
3755
|
+
privilegedKeyManager
|
|
3756
|
+
});
|
|
3757
|
+
const r: SetupWallet = {
|
|
3758
|
+
rootKey,
|
|
3759
|
+
identityKey,
|
|
3760
|
+
keyDeriver,
|
|
3761
|
+
chain,
|
|
3762
|
+
storage,
|
|
3763
|
+
services,
|
|
3764
|
+
monitor,
|
|
3765
|
+
wallet
|
|
3766
|
+
};
|
|
3767
|
+
return r;
|
|
3591
3768
|
}
|
|
3592
3769
|
```
|
|
3770
|
+
See also: [Monitor](#class-monitor), [PrivilegedKeyManager](#class-privilegedkeymanager), [Services](#class-services), [SetupWallet](#interface-setupwallet), [SetupWalletArgs](#interface-setupwalletargs), [Wallet](#class-wallet), [WalletStorageManager](#class-walletstoragemanager)
|
|
3771
|
+
|
|
3772
|
+
#### Method getEnv
|
|
3773
|
+
|
|
3774
|
+
Reads a .env file of the format created by `makeEnv`.
|
|
3593
3775
|
|
|
3594
|
-
|
|
3776
|
+
Returns values for designated `chain`.
|
|
3777
|
+
|
|
3778
|
+
Access private keys through the `devKeys` object: `devKeys[identityKey]`
|
|
3779
|
+
|
|
3780
|
+
```ts
|
|
3781
|
+
static getEnv(chain: sdk.Chain): SetupEnv
|
|
3782
|
+
```
|
|
3783
|
+
See also: [Chain](#type-chain), [SetupEnv](#interface-setupenv)
|
|
3784
|
+
|
|
3785
|
+
Returns
|
|
3786
|
+
|
|
3787
|
+
with configuration environment secrets used by `Setup` functions.
|
|
3788
|
+
|
|
3789
|
+
Argument Details
|
|
3790
|
+
|
|
3791
|
+
+ **chain**
|
|
3792
|
+
+ Which chain to use: 'test' or 'main'
|
|
3793
|
+
|
|
3794
|
+
#### Method makeEnv
|
|
3795
|
+
|
|
3796
|
+
Creates content for .env file with some private keys, identity keys, sample API keys, and sample MySQL connection string.
|
|
3797
|
+
|
|
3798
|
+
Two new, random private keys are generated each time, with their associated public identity keys.
|
|
3799
|
+
|
|
3800
|
+
Loading secrets from a .env file is intended only for experimentation and getting started.
|
|
3801
|
+
Private keys should never be included directly in your source code.
|
|
3802
|
+
|
|
3803
|
+
```ts
|
|
3804
|
+
static makeEnv(): string
|
|
3805
|
+
```
|
|
3806
|
+
|
|
3807
|
+
</details>
|
|
3595
3808
|
|
|
3596
3809
|
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
|
|
3597
3810
|
|
|
@@ -4577,6 +4790,21 @@ See also: [Chain](#type-chain), [KeyPair](#interface-keypair), [Monitor](#class-
|
|
|
4577
4790
|
|
|
4578
4791
|
<summary>Class Wallet Details</summary>
|
|
4579
4792
|
|
|
4793
|
+
#### Property beef
|
|
4794
|
+
|
|
4795
|
+
The wallet creates a `BeefParty` when it is created.
|
|
4796
|
+
All the Beefs that pass through the wallet are merged into this beef.
|
|
4797
|
+
Thus what it contains at any time is the union of all transactions and proof data processed.
|
|
4798
|
+
The class `BeefParty` derives from `Beef`, adding the ability to track the source of merged data.
|
|
4799
|
+
|
|
4800
|
+
This allows it to generate beefs to send to a particular “party” (storage or the user)
|
|
4801
|
+
that includes “txid only proofs” for transactions they already know about.
|
|
4802
|
+
Over time, this allows an active wallet to drastically reduce the amount of data transmitted.
|
|
4803
|
+
|
|
4804
|
+
```ts
|
|
4805
|
+
beef: BeefParty
|
|
4806
|
+
```
|
|
4807
|
+
|
|
4580
4808
|
#### Method getKnownTxids
|
|
4581
4809
|
|
|
4582
4810
|
```ts
|
|
@@ -4750,7 +4978,7 @@ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](
|
|
|
4750
4978
|
---
|
|
4751
4979
|
### Class: WalletStorageManager
|
|
4752
4980
|
|
|
4753
|
-
The `
|
|
4981
|
+
The `WalletStorageManager` class delivers authentication checking storage access to the wallet.
|
|
4754
4982
|
|
|
4755
4983
|
If manages multiple `StorageBase` derived storage services: one actice, the rest as backups.
|
|
4756
4984
|
|