@bsv/wallet-toolbox 1.1.22 → 1.1.24
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/client.md +68 -742
- package/docs/setup.md +145 -150
- package/docs/wallet.md +68 -742
- package/out/src/Setup.d.ts +252 -8
- package/out/src/Setup.d.ts.map +1 -1
- package/out/src/Setup.js +299 -5
- package/out/src/Setup.js.map +1 -1
- package/out/src/index.all.d.ts +0 -1
- package/out/src/index.all.d.ts.map +1 -1
- package/out/src/index.all.js +1 -3
- package/out/src/index.all.js.map +1 -1
- package/out/src/index.client.d.ts +0 -1
- package/out/src/index.client.d.ts.map +1 -1
- package/out/src/index.client.js +1 -3
- package/out/src/index.client.js.map +1 -1
- package/out/tsconfig.all.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/Setup.ts +514 -8
- package/src/index.all.ts +0 -9
- package/src/index.client.ts +0 -1
- package/out/src/SetupClient.d.ts +0 -249
- package/out/src/SetupClient.d.ts.map +0 -1
- package/out/src/SetupClient.js +0 -287
- package/out/src/SetupClient.js.map +0 -1
- package/src/SetupClient.ts +0 -496
package/docs/client.md
CHANGED
|
@@ -14,57 +14,55 @@ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](
|
|
|
14
14
|
|
|
15
15
|
| | | |
|
|
16
16
|
| --- | --- | --- |
|
|
17
|
-
| [ArcConfig](#interface-arcconfig) | [
|
|
18
|
-
| [ArcMinerGetTxData](#interface-arcminergettxdata) | [
|
|
19
|
-
| [AuthId](#interface-authid) | [
|
|
20
|
-
| [BaseBlockHeader](#interface-baseblockheader) | [
|
|
21
|
-
| [BlockHeader](#interface-blockheader) | [
|
|
22
|
-
| [BsvExchangeRate](#interface-bsvexchangerate) | [
|
|
23
|
-
| [CertOpsWallet](#interface-certopswallet) | [
|
|
24
|
-
| [CommitNewTxResults](#interface-commitnewtxresults) | [
|
|
25
|
-
| [EntitySyncMap](#interface-entitysyncmap) | [
|
|
26
|
-
| [EntityTimeStamp](#interface-entitytimestamp) | [
|
|
27
|
-
| [ExchangeRatesIoApi](#interface-exchangeratesioapi) | [
|
|
28
|
-
| [FiatExchangeRates](#interface-fiatexchangerates) | [
|
|
29
|
-
| [FindCertificateFieldsArgs](#interface-findcertificatefieldsargs) | [
|
|
30
|
-
| [FindCertificatesArgs](#interface-findcertificatesargs) | [
|
|
31
|
-
| [FindCommissionsArgs](#interface-findcommissionsargs) | [
|
|
32
|
-
| [FindForUserSincePagedArgs](#interface-findforusersincepagedargs) | [
|
|
33
|
-
| [FindMonitorEventsArgs](#interface-findmonitoreventsargs) | [
|
|
34
|
-
| [FindOutputBasketsArgs](#interface-findoutputbasketsargs) | [
|
|
35
|
-
| [FindOutputTagMapsArgs](#interface-findoutputtagmapsargs) | [
|
|
36
|
-
| [FindOutputTagsArgs](#interface-findoutputtagsargs) | [
|
|
37
|
-
| [FindOutputsArgs](#interface-findoutputsargs) | [
|
|
38
|
-
| [FindPartialSincePagedArgs](#interface-findpartialsincepagedargs) | [
|
|
39
|
-
| [FindProvenTxReqsArgs](#interface-findproventxreqsargs) | [
|
|
40
|
-
| [FindProvenTxsArgs](#interface-findproventxsargs) | [
|
|
41
|
-
| [FindSincePagedArgs](#interface-findsincepagedargs) | [
|
|
42
|
-
| [FindSyncStatesArgs](#interface-findsyncstatesargs) | [
|
|
43
|
-
| [FindTransactionsArgs](#interface-findtransactionsargs) | [
|
|
44
|
-
| [FindTxLabelMapsArgs](#interface-findtxlabelmapsargs) | [
|
|
45
|
-
| [FindTxLabelsArgs](#interface-findtxlabelsargs) | [
|
|
46
|
-
| [FindUsersArgs](#interface-findusersargs) | [
|
|
47
|
-
| [GenerateChangeSdkChangeInput](#interface-generatechangesdkchangeinput) | [
|
|
48
|
-
| [GenerateChangeSdkChangeOutput](#interface-generatechangesdkchangeoutput) | [
|
|
49
|
-
| [GenerateChangeSdkInput](#interface-generatechangesdkinput) | [
|
|
50
|
-
| [GenerateChangeSdkOutput](#interface-generatechangesdkoutput) | [
|
|
51
|
-
| [GenerateChangeSdkParams](#interface-generatechangesdkparams) | [
|
|
52
|
-
| [GenerateChangeSdkResult](#interface-generatechangesdkresult) | [
|
|
53
|
-
| [GenerateChangeSdkStorageChange](#interface-generatechangesdkstoragechange) | [
|
|
54
|
-
| [GetMerklePathResult](#interface-getmerklepathresult) | [
|
|
55
|
-
| [GetRawTxResult](#interface-getrawtxresult) | [
|
|
56
|
-
| [GetReqsAndBeefDetail](#interface-getreqsandbeefdetail) | [
|
|
57
|
-
| [GetReqsAndBeefResult](#interface-getreqsandbeefresult) | [
|
|
58
|
-
| [GetUtxoStatusDetails](#interface-getutxostatusdetails) | [
|
|
59
|
-
| [GetUtxoStatusResult](#interface-getutxostatusresult) | [
|
|
60
|
-
| [KeyPair](#interface-keypair) | [
|
|
61
|
-
| [
|
|
62
|
-
| [
|
|
63
|
-
| [
|
|
64
|
-
| [
|
|
65
|
-
| [
|
|
66
|
-
| [PendingStorageInput](#interface-pendingstorageinput) | [TableOutputTagMap](#interface-tableoutputtagmap) | [WalletStorageWriter](#interface-walletstoragewriter) |
|
|
67
|
-
| [PostBeefResult](#interface-postbeefresult) | [TableOutputX](#interface-tableoutputx) | [XValidCreateActionOutput](#interface-xvalidcreateactionoutput) |
|
|
17
|
+
| [ArcConfig](#interface-arcconfig) | [PostBeefResult](#interface-postbeefresult) | [TableProvenTxReqDynamics](#interface-tableproventxreqdynamics) |
|
|
18
|
+
| [ArcMinerGetTxData](#interface-arcminergettxdata) | [PostBeefResultForTxidApi](#interface-postbeefresultfortxidapi) | [TableSettings](#interface-tablesettings) |
|
|
19
|
+
| [AuthId](#interface-authid) | [PostReqsToNetworkDetails](#interface-postreqstonetworkdetails) | [TableSyncState](#interface-tablesyncstate) |
|
|
20
|
+
| [BaseBlockHeader](#interface-baseblockheader) | [PostReqsToNetworkResult](#interface-postreqstonetworkresult) | [TableTransaction](#interface-tabletransaction) |
|
|
21
|
+
| [BlockHeader](#interface-blockheader) | [PostTxResultForTxid](#interface-posttxresultfortxid) | [TableTxLabel](#interface-tabletxlabel) |
|
|
22
|
+
| [BsvExchangeRate](#interface-bsvexchangerate) | [PostTxResultForTxidError](#interface-posttxresultfortxiderror) | [TableTxLabelMap](#interface-tabletxlabelmap) |
|
|
23
|
+
| [CertOpsWallet](#interface-certopswallet) | [PostTxsResult](#interface-posttxsresult) | [TableUser](#interface-tableuser) |
|
|
24
|
+
| [CommitNewTxResults](#interface-commitnewtxresults) | [ProcessSyncChunkResult](#interface-processsyncchunkresult) | [TaskPurgeParams](#interface-taskpurgeparams) |
|
|
25
|
+
| [EntitySyncMap](#interface-entitysyncmap) | [ProvenOrRawTx](#interface-provenorrawtx) | [TrxToken](#interface-trxtoken) |
|
|
26
|
+
| [EntityTimeStamp](#interface-entitytimestamp) | [ProvenTxFromTxidResult](#interface-proventxfromtxidresult) | [TscMerkleProofApi](#interface-tscmerkleproofapi) |
|
|
27
|
+
| [ExchangeRatesIoApi](#interface-exchangeratesioapi) | [ProvenTxReqHistory](#interface-proventxreqhistory) | [TxScriptOffsets](#interface-txscriptoffsets) |
|
|
28
|
+
| [FiatExchangeRates](#interface-fiatexchangerates) | [ProvenTxReqHistorySummaryApi](#interface-proventxreqhistorysummaryapi) | [UpdateProvenTxReqWithNewProvenTxArgs](#interface-updateproventxreqwithnewproventxargs) |
|
|
29
|
+
| [FindCertificateFieldsArgs](#interface-findcertificatefieldsargs) | [ProvenTxReqNotify](#interface-proventxreqnotify) | [UpdateProvenTxReqWithNewProvenTxResult](#interface-updateproventxreqwithnewproventxresult) |
|
|
30
|
+
| [FindCertificatesArgs](#interface-findcertificatesargs) | [PurgeParams](#interface-purgeparams) | [ValidAbortActionArgs](#interface-validabortactionargs) |
|
|
31
|
+
| [FindCommissionsArgs](#interface-findcommissionsargs) | [PurgeResults](#interface-purgeresults) | [ValidAcquireCertificateArgs](#interface-validacquirecertificateargs) |
|
|
32
|
+
| [FindForUserSincePagedArgs](#interface-findforusersincepagedargs) | [RequestSyncChunkArgs](#interface-requestsyncchunkargs) | [ValidAcquireDirectCertificateArgs](#interface-validacquiredirectcertificateargs) |
|
|
33
|
+
| [FindMonitorEventsArgs](#interface-findmonitoreventsargs) | [ScriptTemplateParamsBRC29](#interface-scripttemplateparamsbrc29) | [ValidAcquireIssuanceCertificateArgs](#interface-validacquireissuancecertificateargs) |
|
|
34
|
+
| [FindOutputBasketsArgs](#interface-findoutputbasketsargs) | [ScriptTemplateUnlock](#interface-scripttemplateunlock) | [ValidBasketInsertion](#interface-validbasketinsertion) |
|
|
35
|
+
| [FindOutputTagMapsArgs](#interface-findoutputtagmapsargs) | [StorageCreateActionResult](#interface-storagecreateactionresult) | [ValidCreateActionArgs](#interface-validcreateactionargs) |
|
|
36
|
+
| [FindOutputTagsArgs](#interface-findoutputtagsargs) | [StorageCreateTransactionSdkInput](#interface-storagecreatetransactionsdkinput) | [ValidCreateActionInput](#interface-validcreateactioninput) |
|
|
37
|
+
| [FindOutputsArgs](#interface-findoutputsargs) | [StorageCreateTransactionSdkOutput](#interface-storagecreatetransactionsdkoutput) | [ValidCreateActionOptions](#interface-validcreateactionoptions) |
|
|
38
|
+
| [FindPartialSincePagedArgs](#interface-findpartialsincepagedargs) | [StorageFeeModel](#interface-storagefeemodel) | [ValidCreateActionOutput](#interface-validcreateactionoutput) |
|
|
39
|
+
| [FindProvenTxReqsArgs](#interface-findproventxreqsargs) | [StorageGetBeefOptions](#interface-storagegetbeefoptions) | [ValidDiscoverByAttributesArgs](#interface-validdiscoverbyattributesargs) |
|
|
40
|
+
| [FindProvenTxsArgs](#interface-findproventxsargs) | [StorageIdentity](#interface-storageidentity) | [ValidDiscoverByIdentityKeyArgs](#interface-validdiscoverbyidentitykeyargs) |
|
|
41
|
+
| [FindSincePagedArgs](#interface-findsincepagedargs) | [StorageInternalizeActionResult](#interface-storageinternalizeactionresult) | [ValidInternalizeActionArgs](#interface-validinternalizeactionargs) |
|
|
42
|
+
| [FindSyncStatesArgs](#interface-findsyncstatesargs) | [StorageProcessActionArgs](#interface-storageprocessactionargs) | [ValidInternalizeOutput](#interface-validinternalizeoutput) |
|
|
43
|
+
| [FindTransactionsArgs](#interface-findtransactionsargs) | [StorageProcessActionResults](#interface-storageprocessactionresults) | [ValidListActionsArgs](#interface-validlistactionsargs) |
|
|
44
|
+
| [FindTxLabelMapsArgs](#interface-findtxlabelmapsargs) | [StorageProvenOrReq](#interface-storageprovenorreq) | [ValidListCertificatesArgs](#interface-validlistcertificatesargs) |
|
|
45
|
+
| [FindTxLabelsArgs](#interface-findtxlabelsargs) | [StorageProviderOptions](#interface-storageprovideroptions) | [ValidListOutputsArgs](#interface-validlistoutputsargs) |
|
|
46
|
+
| [FindUsersArgs](#interface-findusersargs) | [StorageReaderOptions](#interface-storagereaderoptions) | [ValidProcessActionArgs](#interface-validprocessactionargs) |
|
|
47
|
+
| [GenerateChangeSdkChangeInput](#interface-generatechangesdkchangeinput) | [StorageReaderWriterOptions](#interface-storagereaderwriteroptions) | [ValidProcessActionOptions](#interface-validprocessactionoptions) |
|
|
48
|
+
| [GenerateChangeSdkChangeOutput](#interface-generatechangesdkchangeoutput) | [StorageSyncReader](#interface-storagesyncreader) | [ValidProveCertificateArgs](#interface-validprovecertificateargs) |
|
|
49
|
+
| [GenerateChangeSdkInput](#interface-generatechangesdkinput) | [StorageSyncReaderOptions](#interface-storagesyncreaderoptions) | [ValidRelinquishCertificateArgs](#interface-validrelinquishcertificateargs) |
|
|
50
|
+
| [GenerateChangeSdkOutput](#interface-generatechangesdkoutput) | [StorageSyncReaderWriter](#interface-storagesyncreaderwriter) | [ValidRelinquishOutputArgs](#interface-validrelinquishoutputargs) |
|
|
51
|
+
| [GenerateChangeSdkParams](#interface-generatechangesdkparams) | [SyncChunk](#interface-syncchunk) | [ValidSignActionArgs](#interface-validsignactionargs) |
|
|
52
|
+
| [GenerateChangeSdkResult](#interface-generatechangesdkresult) | [SyncError](#interface-syncerror) | [ValidSignActionOptions](#interface-validsignactionoptions) |
|
|
53
|
+
| [GenerateChangeSdkStorageChange](#interface-generatechangesdkstoragechange) | [SyncMap](#interface-syncmap) | [ValidWalletPayment](#interface-validwalletpayment) |
|
|
54
|
+
| [GetMerklePathResult](#interface-getmerklepathresult) | [TableCertificate](#interface-tablecertificate) | [ValidWalletSignerArgs](#interface-validwalletsignerargs) |
|
|
55
|
+
| [GetRawTxResult](#interface-getrawtxresult) | [TableCertificateField](#interface-tablecertificatefield) | [ValidateGenerateChangeSdkParamsResult](#interface-validategeneratechangesdkparamsresult) |
|
|
56
|
+
| [GetReqsAndBeefDetail](#interface-getreqsandbeefdetail) | [TableCertificateX](#interface-tablecertificatex) | [WalletArgs](#interface-walletargs) |
|
|
57
|
+
| [GetReqsAndBeefResult](#interface-getreqsandbeefresult) | [TableCommission](#interface-tablecommission) | [WalletServices](#interface-walletservices) |
|
|
58
|
+
| [GetUtxoStatusDetails](#interface-getutxostatusdetails) | [TableMonitorEvent](#interface-tablemonitorevent) | [WalletServicesOptions](#interface-walletservicesoptions) |
|
|
59
|
+
| [GetUtxoStatusResult](#interface-getutxostatusresult) | [TableOutput](#interface-tableoutput) | [WalletSigner](#interface-walletsigner) |
|
|
60
|
+
| [KeyPair](#interface-keypair) | [TableOutputBasket](#interface-tableoutputbasket) | [WalletStorage](#interface-walletstorage) |
|
|
61
|
+
| [MonitorOptions](#interface-monitoroptions) | [TableOutputTag](#interface-tableoutputtag) | [WalletStorageProvider](#interface-walletstorageprovider) |
|
|
62
|
+
| [OutPoint](#interface-outpoint) | [TableOutputTagMap](#interface-tableoutputtagmap) | [WalletStorageReader](#interface-walletstoragereader) |
|
|
63
|
+
| [Paged](#interface-paged) | [TableOutputX](#interface-tableoutputx) | [WalletStorageSync](#interface-walletstoragesync) |
|
|
64
|
+
| [PendingSignAction](#interface-pendingsignaction) | [TableProvenTx](#interface-tableproventx) | [WalletStorageWriter](#interface-walletstoragewriter) |
|
|
65
|
+
| [PendingStorageInput](#interface-pendingstorageinput) | [TableProvenTxReq](#interface-tableproventxreq) | [XValidCreateActionOutput](#interface-xvalidcreateactionoutput) |
|
|
68
66
|
|
|
69
67
|
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
|
|
70
68
|
|
|
@@ -1047,21 +1045,6 @@ export interface KeyPair {
|
|
|
1047
1045
|
|
|
1048
1046
|
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
|
|
1049
1047
|
|
|
1050
|
-
---
|
|
1051
|
-
##### Interface: KeyPairAddress
|
|
1052
|
-
|
|
1053
|
-
A private key and associated public key and address.
|
|
1054
|
-
|
|
1055
|
-
```ts
|
|
1056
|
-
export interface KeyPairAddress {
|
|
1057
|
-
privateKey: PrivateKey;
|
|
1058
|
-
publicKey: PublicKey;
|
|
1059
|
-
address: string;
|
|
1060
|
-
}
|
|
1061
|
-
```
|
|
1062
|
-
|
|
1063
|
-
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
|
|
1064
|
-
|
|
1065
1048
|
---
|
|
1066
1049
|
##### Interface: MonitorOptions
|
|
1067
1050
|
|
|
@@ -1624,315 +1607,6 @@ export interface ScriptTemplateUnlock {
|
|
|
1624
1607
|
|
|
1625
1608
|
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
|
|
1626
1609
|
|
|
1627
|
-
---
|
|
1628
|
-
##### Interface: SetupEnv
|
|
1629
|
-
|
|
1630
|
-
`SetupEnv` provides a starting point for managing secrets that
|
|
1631
|
-
must not appear in source code.
|
|
1632
|
-
|
|
1633
|
-
The `makeEnv` and `getEnv` functions of the `Setup` and `SetupClient` classes
|
|
1634
|
-
provide an easy way to create and import these secrets and related properties.
|
|
1635
|
-
|
|
1636
|
-
```ts
|
|
1637
|
-
export interface SetupEnv {
|
|
1638
|
-
chain: sdk.Chain;
|
|
1639
|
-
identityKey: string;
|
|
1640
|
-
identityKey2: string;
|
|
1641
|
-
filePath: string | undefined;
|
|
1642
|
-
taalApiKey: string;
|
|
1643
|
-
devKeys: Record<string, string>;
|
|
1644
|
-
mySQLConnection: string;
|
|
1645
|
-
}
|
|
1646
|
-
```
|
|
1647
|
-
|
|
1648
|
-
See also: [Chain](./client.md#type-chain)
|
|
1649
|
-
|
|
1650
|
-
###### Property chain
|
|
1651
|
-
|
|
1652
|
-
The chan being accessed: 'main' for mainnet, 'test' for 'testnet'.
|
|
1653
|
-
|
|
1654
|
-
```ts
|
|
1655
|
-
chain: sdk.Chain
|
|
1656
|
-
```
|
|
1657
|
-
See also: [Chain](./client.md#type-chain)
|
|
1658
|
-
|
|
1659
|
-
###### Property devKeys
|
|
1660
|
-
|
|
1661
|
-
A map of public keys (identity keys, hex strings) to private keys (hex strings).
|
|
1662
|
-
|
|
1663
|
-
```ts
|
|
1664
|
-
devKeys: Record<string, string>
|
|
1665
|
-
```
|
|
1666
|
-
|
|
1667
|
-
###### Property filePath
|
|
1668
|
-
|
|
1669
|
-
Filepath to sqlite file to be used for identityKey wallet.
|
|
1670
|
-
|
|
1671
|
-
```ts
|
|
1672
|
-
filePath: string | undefined
|
|
1673
|
-
```
|
|
1674
|
-
|
|
1675
|
-
###### Property identityKey
|
|
1676
|
-
|
|
1677
|
-
The user's primary identity key (public key).
|
|
1678
|
-
|
|
1679
|
-
```ts
|
|
1680
|
-
identityKey: string
|
|
1681
|
-
```
|
|
1682
|
-
|
|
1683
|
-
###### Property identityKey2
|
|
1684
|
-
|
|
1685
|
-
A secondary identity key (public key), used to test exchanges with other users.
|
|
1686
|
-
|
|
1687
|
-
```ts
|
|
1688
|
-
identityKey2: string
|
|
1689
|
-
```
|
|
1690
|
-
|
|
1691
|
-
###### Property mySQLConnection
|
|
1692
|
-
|
|
1693
|
-
A MySQL connection string including user and password properties.
|
|
1694
|
-
Must be valid to make use of MySQL `Setup` class support.
|
|
1695
|
-
|
|
1696
|
-
```ts
|
|
1697
|
-
mySQLConnection: string
|
|
1698
|
-
```
|
|
1699
|
-
|
|
1700
|
-
###### Property taalApiKey
|
|
1701
|
-
|
|
1702
|
-
A vaild TAAL API key for use by `Services`
|
|
1703
|
-
|
|
1704
|
-
```ts
|
|
1705
|
-
taalApiKey: string
|
|
1706
|
-
```
|
|
1707
|
-
|
|
1708
|
-
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
|
|
1709
|
-
|
|
1710
|
-
---
|
|
1711
|
-
##### Interface: SetupWallet
|
|
1712
|
-
|
|
1713
|
-
When creating a BRC-100 compatible `Wallet`, many components come into play.
|
|
1714
|
-
|
|
1715
|
-
All of the `createWallet` functions in the `Setup` and `SetupClient` classes return
|
|
1716
|
-
an object with direct access to each component to facilitate experimentation, testing
|
|
1717
|
-
and customization.
|
|
1718
|
-
|
|
1719
|
-
```ts
|
|
1720
|
-
export interface SetupWallet {
|
|
1721
|
-
rootKey: PrivateKey;
|
|
1722
|
-
identityKey: string;
|
|
1723
|
-
keyDeriver: KeyDeriver;
|
|
1724
|
-
chain: sdk.Chain;
|
|
1725
|
-
storage: WalletStorageManager;
|
|
1726
|
-
services: Services;
|
|
1727
|
-
monitor: Monitor;
|
|
1728
|
-
wallet: Wallet;
|
|
1729
|
-
}
|
|
1730
|
-
```
|
|
1731
|
-
|
|
1732
|
-
See also: [Chain](./client.md#type-chain), [Monitor](./monitor.md#class-monitor), [Services](./services.md#class-services), [Wallet](./client.md#class-wallet), [WalletStorageManager](./storage.md#class-walletstoragemanager)
|
|
1733
|
-
|
|
1734
|
-
###### Property chain
|
|
1735
|
-
|
|
1736
|
-
The chain ('main' or 'test') which the wallet accesses.
|
|
1737
|
-
|
|
1738
|
-
```ts
|
|
1739
|
-
chain: sdk.Chain
|
|
1740
|
-
```
|
|
1741
|
-
See also: [Chain](./client.md#type-chain)
|
|
1742
|
-
|
|
1743
|
-
###### Property identityKey
|
|
1744
|
-
|
|
1745
|
-
The pubilc key associated with the `rootKey` which also serves as the wallet's identity.
|
|
1746
|
-
|
|
1747
|
-
```ts
|
|
1748
|
-
identityKey: string
|
|
1749
|
-
```
|
|
1750
|
-
|
|
1751
|
-
###### Property keyDeriver
|
|
1752
|
-
|
|
1753
|
-
The `KeyDeriver` component used by the wallet for key derivation and cryptographic functions.
|
|
1754
|
-
|
|
1755
|
-
```ts
|
|
1756
|
-
keyDeriver: KeyDeriver
|
|
1757
|
-
```
|
|
1758
|
-
|
|
1759
|
-
###### Property monitor
|
|
1760
|
-
|
|
1761
|
-
The background task `Monitor` component available to the wallet to offload tasks
|
|
1762
|
-
that speed up wallet operations and maintain data integrity.
|
|
1763
|
-
|
|
1764
|
-
```ts
|
|
1765
|
-
monitor: Monitor
|
|
1766
|
-
```
|
|
1767
|
-
See also: [Monitor](./monitor.md#class-monitor)
|
|
1768
|
-
|
|
1769
|
-
###### Property rootKey
|
|
1770
|
-
|
|
1771
|
-
The rootKey of the `KeyDeriver`. The private key from which other keys are derived.
|
|
1772
|
-
|
|
1773
|
-
```ts
|
|
1774
|
-
rootKey: PrivateKey
|
|
1775
|
-
```
|
|
1776
|
-
|
|
1777
|
-
###### Property services
|
|
1778
|
-
|
|
1779
|
-
The network `Services` component which provides the wallet with access to external services hosted
|
|
1780
|
-
on the public network.
|
|
1781
|
-
|
|
1782
|
-
```ts
|
|
1783
|
-
services: Services
|
|
1784
|
-
```
|
|
1785
|
-
See also: [Services](./services.md#class-services)
|
|
1786
|
-
|
|
1787
|
-
###### Property storage
|
|
1788
|
-
|
|
1789
|
-
The `WalletStorageManager` that manages all the configured storage providers (active and backups)
|
|
1790
|
-
accessed by the wallet.
|
|
1791
|
-
|
|
1792
|
-
```ts
|
|
1793
|
-
storage: WalletStorageManager
|
|
1794
|
-
```
|
|
1795
|
-
See also: [WalletStorageManager](./storage.md#class-walletstoragemanager)
|
|
1796
|
-
|
|
1797
|
-
###### Property wallet
|
|
1798
|
-
|
|
1799
|
-
The actual BRC-100 `Wallet` to which all the other properties and components contribute.
|
|
1800
|
-
|
|
1801
|
-
Note that internally, the wallet is itself linked to all these properties and components.
|
|
1802
|
-
They are included in this interface to facilitate access after wallet construction for
|
|
1803
|
-
experimentation, testing and customization. Any changes made to the configuration of these
|
|
1804
|
-
components after construction may disrupt the normal operation of the wallet.
|
|
1805
|
-
|
|
1806
|
-
```ts
|
|
1807
|
-
wallet: Wallet
|
|
1808
|
-
```
|
|
1809
|
-
See also: [Wallet](./client.md#class-wallet)
|
|
1810
|
-
|
|
1811
|
-
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
|
|
1812
|
-
|
|
1813
|
-
---
|
|
1814
|
-
##### Interface: SetupWalletArgs
|
|
1815
|
-
|
|
1816
|
-
Arguments used by `createWallet` to construct a `SetupWallet`.
|
|
1817
|
-
|
|
1818
|
-
Extension `SetupWalletClientArgs` used by `createWalletClient` to construct a `SetupWalletClient`.
|
|
1819
|
-
|
|
1820
|
-
Extension `SetupWalletKnexArgs` used by `createWalletKnex` to construct a `SetupWalletKnex`.
|
|
1821
|
-
|
|
1822
|
-
Extension `SetupWalletMySQLArgs` used by `createWalletMySQL` to construct a `SetupWalletKnex`.
|
|
1823
|
-
|
|
1824
|
-
Extension `SetupWalletSQLiteArgs` used by `createWalletSQLite` to construct a `SetupWalletKnex`.
|
|
1825
|
-
|
|
1826
|
-
```ts
|
|
1827
|
-
export interface SetupWalletArgs {
|
|
1828
|
-
env: SetupEnv;
|
|
1829
|
-
rootKeyHex?: string;
|
|
1830
|
-
privKeyHex?: string;
|
|
1831
|
-
active?: sdk.WalletStorageProvider;
|
|
1832
|
-
backups?: sdk.WalletStorageProvider[];
|
|
1833
|
-
}
|
|
1834
|
-
```
|
|
1835
|
-
|
|
1836
|
-
See also: [SetupEnv](./setup.md#interface-setupenv), [WalletStorageProvider](./client.md#interface-walletstorageprovider)
|
|
1837
|
-
|
|
1838
|
-
###### Property active
|
|
1839
|
-
|
|
1840
|
-
Optional. Active wallet storage. Can be added later.
|
|
1841
|
-
|
|
1842
|
-
```ts
|
|
1843
|
-
active?: sdk.WalletStorageProvider
|
|
1844
|
-
```
|
|
1845
|
-
See also: [WalletStorageProvider](./client.md#interface-walletstorageprovider)
|
|
1846
|
-
|
|
1847
|
-
###### Property backups
|
|
1848
|
-
|
|
1849
|
-
Optional. One or more storage providers managed as backup destinations. Can be added later.
|
|
1850
|
-
|
|
1851
|
-
```ts
|
|
1852
|
-
backups?: sdk.WalletStorageProvider[]
|
|
1853
|
-
```
|
|
1854
|
-
See also: [WalletStorageProvider](./client.md#interface-walletstorageprovider)
|
|
1855
|
-
|
|
1856
|
-
###### Property env
|
|
1857
|
-
|
|
1858
|
-
Configuration "secrets" typically obtained by `Setup.makeEnv` and `Setup.getEnv` functions.
|
|
1859
|
-
|
|
1860
|
-
```ts
|
|
1861
|
-
env: SetupEnv
|
|
1862
|
-
```
|
|
1863
|
-
See also: [SetupEnv](./setup.md#interface-setupenv)
|
|
1864
|
-
|
|
1865
|
-
###### Property privKeyHex
|
|
1866
|
-
|
|
1867
|
-
Optional. The privileged private key used to initialize the `PrivilegedKeyManager`.
|
|
1868
|
-
Defaults to undefined.
|
|
1869
|
-
|
|
1870
|
-
```ts
|
|
1871
|
-
privKeyHex?: string
|
|
1872
|
-
```
|
|
1873
|
-
|
|
1874
|
-
###### Property rootKeyHex
|
|
1875
|
-
|
|
1876
|
-
Optional. The non-privileged private key used to initialize the `KeyDeriver` and determine the `identityKey`.
|
|
1877
|
-
Defaults to `env.devKeys[env.identityKey]
|
|
1878
|
-
|
|
1879
|
-
```ts
|
|
1880
|
-
rootKeyHex?: string
|
|
1881
|
-
```
|
|
1882
|
-
|
|
1883
|
-
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
|
|
1884
|
-
|
|
1885
|
-
---
|
|
1886
|
-
##### Interface: SetupWalletClient
|
|
1887
|
-
|
|
1888
|
-
Extension `SetupWalletClient` of `SetupWallet` is returned by `createWalletClient`
|
|
1889
|
-
|
|
1890
|
-
```ts
|
|
1891
|
-
export interface SetupWalletClient extends SetupWallet {
|
|
1892
|
-
endpointUrl: string;
|
|
1893
|
-
}
|
|
1894
|
-
```
|
|
1895
|
-
|
|
1896
|
-
See also: [SetupWallet](./setup.md#interface-setupwallet)
|
|
1897
|
-
|
|
1898
|
-
###### Property endpointUrl
|
|
1899
|
-
|
|
1900
|
-
The endpoint URL of the service hosting the `StorageServer` JSON-RPC service to
|
|
1901
|
-
which a `StorageClient` instance is connected to function as
|
|
1902
|
-
the active storage provider of the wallet.
|
|
1903
|
-
|
|
1904
|
-
```ts
|
|
1905
|
-
endpointUrl: string
|
|
1906
|
-
```
|
|
1907
|
-
|
|
1908
|
-
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
|
|
1909
|
-
|
|
1910
|
-
---
|
|
1911
|
-
##### Interface: SetupWalletClientArgs
|
|
1912
|
-
|
|
1913
|
-
Extension `SetupWalletClientArgs` of `SetupWalletArgs` is used by `createWalletClient`
|
|
1914
|
-
to construct a `SetupWalletClient`.
|
|
1915
|
-
|
|
1916
|
-
```ts
|
|
1917
|
-
export interface SetupWalletClientArgs extends SetupWalletArgs {
|
|
1918
|
-
endpointUrl?: string;
|
|
1919
|
-
}
|
|
1920
|
-
```
|
|
1921
|
-
|
|
1922
|
-
See also: [SetupWalletArgs](./setup.md#interface-setupwalletargs)
|
|
1923
|
-
|
|
1924
|
-
###### Property endpointUrl
|
|
1925
|
-
|
|
1926
|
-
The endpoint URL of a service hosting the `StorageServer` JSON-RPC service to
|
|
1927
|
-
which a `StorageClient` instance should connect to function as
|
|
1928
|
-
the active storage provider of the newly created wallet.
|
|
1929
|
-
|
|
1930
|
-
```ts
|
|
1931
|
-
endpointUrl?: string
|
|
1932
|
-
```
|
|
1933
|
-
|
|
1934
|
-
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
|
|
1935
|
-
|
|
1936
1610
|
---
|
|
1937
1611
|
##### Interface: StorageCreateActionResult
|
|
1938
1612
|
|
|
@@ -4042,25 +3716,25 @@ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](
|
|
|
4042
3716
|
|
|
4043
3717
|
| | | |
|
|
4044
3718
|
| --- | --- | --- |
|
|
4045
|
-
| [ARC](#class-arc) | [PrivilegedKeyManager](#class-privilegedkeymanager) | [
|
|
4046
|
-
| [CertOps](#class-certops) | [ScriptTemplateBRC29](#class-scripttemplatebrc29) | [
|
|
4047
|
-
| [EntityBase](#class-entitybase) | [SdkWhatsOnChain](#class-sdkwhatsonchain) | [
|
|
4048
|
-
| [EntityCertificate](#class-entitycertificate) | [ServiceCollection](#class-servicecollection) | [
|
|
4049
|
-
| [EntityCertificateField](#class-entitycertificatefield) | [Services](#class-services) | [
|
|
4050
|
-
| [EntityCommission](#class-entitycommission) | [
|
|
4051
|
-
| [EntityOutput](#class-entityoutput) | [
|
|
4052
|
-
| [EntityOutputBasket](#class-entityoutputbasket) | [
|
|
4053
|
-
| [EntityOutputTag](#class-entityoutputtag) | [
|
|
4054
|
-
| [EntityOutputTagMap](#class-entityoutputtagmap) | [
|
|
4055
|
-
| [EntityProvenTx](#class-entityproventx) | [
|
|
4056
|
-
| [EntityProvenTxReq](#class-entityproventxreq) | [
|
|
4057
|
-
| [EntitySyncState](#class-entitysyncstate) | [
|
|
4058
|
-
| [EntityTransaction](#class-entitytransaction) | [
|
|
4059
|
-
| [EntityTxLabel](#class-entitytxlabel) | [
|
|
4060
|
-
| [EntityTxLabelMap](#class-entitytxlabelmap) | [
|
|
4061
|
-
| [EntityUser](#class-entityuser) | [
|
|
4062
|
-
| [MergeEntity](#class-mergeentity) | [
|
|
4063
|
-
| [Monitor](#class-monitor) | [
|
|
3719
|
+
| [ARC](#class-arc) | [PrivilegedKeyManager](#class-privilegedkeymanager) | [WERR_BROADCAST_UNAVAILABLE](#class-werr_broadcast_unavailable) |
|
|
3720
|
+
| [CertOps](#class-certops) | [ScriptTemplateBRC29](#class-scripttemplatebrc29) | [WERR_INSUFFICIENT_FUNDS](#class-werr_insufficient_funds) |
|
|
3721
|
+
| [EntityBase](#class-entitybase) | [SdkWhatsOnChain](#class-sdkwhatsonchain) | [WERR_INTERNAL](#class-werr_internal) |
|
|
3722
|
+
| [EntityCertificate](#class-entitycertificate) | [ServiceCollection](#class-servicecollection) | [WERR_INVALID_OPERATION](#class-werr_invalid_operation) |
|
|
3723
|
+
| [EntityCertificateField](#class-entitycertificatefield) | [Services](#class-services) | [WERR_INVALID_PARAMETER](#class-werr_invalid_parameter) |
|
|
3724
|
+
| [EntityCommission](#class-entitycommission) | [StorageClient](#class-storageclient) | [WERR_INVALID_PUBLIC_KEY](#class-werr_invalid_public_key) |
|
|
3725
|
+
| [EntityOutput](#class-entityoutput) | [StorageProvider](#class-storageprovider) | [WERR_MISSING_PARAMETER](#class-werr_missing_parameter) |
|
|
3726
|
+
| [EntityOutputBasket](#class-entityoutputbasket) | [StorageReader](#class-storagereader) | [WERR_NETWORK_CHAIN](#class-werr_network_chain) |
|
|
3727
|
+
| [EntityOutputTag](#class-entityoutputtag) | [StorageReaderWriter](#class-storagereaderwriter) | [WERR_NOT_ACTIVE](#class-werr_not_active) |
|
|
3728
|
+
| [EntityOutputTagMap](#class-entityoutputtagmap) | [StorageSyncReader](#class-storagesyncreader) | [WERR_NOT_IMPLEMENTED](#class-werr_not_implemented) |
|
|
3729
|
+
| [EntityProvenTx](#class-entityproventx) | [TaskCheckForProofs](#class-taskcheckforproofs) | [WERR_UNAUTHORIZED](#class-werr_unauthorized) |
|
|
3730
|
+
| [EntityProvenTxReq](#class-entityproventxreq) | [TaskClock](#class-taskclock) | [Wallet](#class-wallet) |
|
|
3731
|
+
| [EntitySyncState](#class-entitysyncstate) | [TaskFailAbandoned](#class-taskfailabandoned) | [WalletError](#class-walleterror) |
|
|
3732
|
+
| [EntityTransaction](#class-entitytransaction) | [TaskNewHeader](#class-tasknewheader) | [WalletMonitorTask](#class-walletmonitortask) |
|
|
3733
|
+
| [EntityTxLabel](#class-entitytxlabel) | [TaskPurge](#class-taskpurge) | [WalletSigner](#class-walletsigner) |
|
|
3734
|
+
| [EntityTxLabelMap](#class-entitytxlabelmap) | [TaskReviewStatus](#class-taskreviewstatus) | [WalletStorageManager](#class-walletstoragemanager) |
|
|
3735
|
+
| [EntityUser](#class-entityuser) | [TaskSendWaiting](#class-tasksendwaiting) | [WhatsOnChain](#class-whatsonchain) |
|
|
3736
|
+
| [MergeEntity](#class-mergeentity) | [TaskSyncWhenIdle](#class-tasksyncwhenidle) | |
|
|
3737
|
+
| [Monitor](#class-monitor) | [WERR_BAD_REQUEST](#class-werr_bad_request) | |
|
|
4064
3738
|
|
|
4065
3739
|
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
|
|
4066
3740
|
|
|
@@ -5526,354 +5200,6 @@ See also: [ARC](./services.md#class-arc), [BlockHeader](./client.md#interface-bl
|
|
|
5526
5200
|
|
|
5527
5201
|
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
|
|
5528
5202
|
|
|
5529
|
-
---
|
|
5530
|
-
##### Class: SetupClient
|
|
5531
|
-
|
|
5532
|
-
The `SetupClient` class provides static setup functions to construct BRC-100 compatible
|
|
5533
|
-
wallets in a variety of configurations.
|
|
5534
|
-
|
|
5535
|
-
It serves as a starting point for experimentation and customization.
|
|
5536
|
-
|
|
5537
|
-
`SetupClient` references only browser compatible code including storage via `StorageClient`.
|
|
5538
|
-
`Setup` extends `SetupClient` adding database storage via `Knex` and `StorageKnex`.
|
|
5539
|
-
|
|
5540
|
-
```ts
|
|
5541
|
-
export abstract class SetupClient {
|
|
5542
|
-
static noEnv(chain: sdk.Chain): boolean
|
|
5543
|
-
static makeEnv(): string {
|
|
5544
|
-
const testPrivKey1 = PrivateKey.fromRandom();
|
|
5545
|
-
const testIdentityKey1 = testPrivKey1.toPublicKey().toString();
|
|
5546
|
-
const testPrivKey2 = PrivateKey.fromRandom();
|
|
5547
|
-
const testIdentityKey2 = testPrivKey2.toPublicKey().toString();
|
|
5548
|
-
const mainPrivKey1 = PrivateKey.fromRandom();
|
|
5549
|
-
const mainIdentityKey1 = mainPrivKey1.toPublicKey().toString();
|
|
5550
|
-
const mainPrivKey2 = PrivateKey.fromRandom();
|
|
5551
|
-
const mainIdentityKey2 = mainPrivKey2.toPublicKey().toString();
|
|
5552
|
-
const log = `
|
|
5553
|
-
# .env file template for working with wallet-toolbox Setup functions.
|
|
5554
|
-
MY_TEST_IDENTITY = '${testIdentityKey1}'
|
|
5555
|
-
MY_TEST_IDENTITY2 = '${testIdentityKey2}'
|
|
5556
|
-
MY_MAIN_IDENTITY = '${mainIdentityKey1}'
|
|
5557
|
-
MY_MAIN_IDENTITY2 = '${mainIdentityKey2}'
|
|
5558
|
-
MAIN_TAAL_API_KEY='mainnet_9596de07e92300c6287e4393594ae39c'
|
|
5559
|
-
TEST_TAAL_API_KEY='testnet_0e6cf72133b43ea2d7861da2a38684e3'
|
|
5560
|
-
MYSQL_CONNECTION='{"port":3306,"host":"127.0.0.1","user":"root","password":"your_password","database":"your_database", "timezone": "Z"}'
|
|
5561
|
-
DEV_KEYS = '{
|
|
5562
|
-
"${testIdentityKey1}": "${testPrivKey1.toString()}",
|
|
5563
|
-
"${testIdentityKey2}": "${testPrivKey2.toString()}",
|
|
5564
|
-
"${mainIdentityKey1}": "${mainPrivKey1.toString()}",
|
|
5565
|
-
"${mainIdentityKey2}": "${mainPrivKey2.toString()}"
|
|
5566
|
-
}'
|
|
5567
|
-
`;
|
|
5568
|
-
console.log(log);
|
|
5569
|
-
return log;
|
|
5570
|
-
}
|
|
5571
|
-
static getEnv(chain: sdk.Chain): SetupEnv {
|
|
5572
|
-
const identityKey = chain === "main"
|
|
5573
|
-
? process.env.MY_MAIN_IDENTITY
|
|
5574
|
-
: process.env.MY_TEST_IDENTITY;
|
|
5575
|
-
const identityKey2 = chain === "main"
|
|
5576
|
-
? process.env.MY_MAIN_IDENTITY2
|
|
5577
|
-
: process.env.MY_TEST_IDENTITY2;
|
|
5578
|
-
const filePath = chain === "main"
|
|
5579
|
-
? process.env.MY_MAIN_FILEPATH
|
|
5580
|
-
: process.env.MY_TEST_FILEPATH;
|
|
5581
|
-
const DEV_KEYS = process.env.DEV_KEYS || "{}";
|
|
5582
|
-
const mySQLConnection = process.env.MYSQL_CONNECTION || "{}";
|
|
5583
|
-
const taalApiKey = verifyTruthy(chain === "main"
|
|
5584
|
-
? process.env.MAIN_TAAL_API_KEY
|
|
5585
|
-
: process.env.TEST_TAAL_API_KEY, `.env value for '${chain.toUpperCase()}_TAAL_API_KEY' is required.`);
|
|
5586
|
-
if (!identityKey || !identityKey2)
|
|
5587
|
-
throw new sdk.WERR_INVALID_OPERATION(".env is not a valid SetupEnv configuration.");
|
|
5588
|
-
return {
|
|
5589
|
-
chain,
|
|
5590
|
-
identityKey,
|
|
5591
|
-
identityKey2,
|
|
5592
|
-
filePath,
|
|
5593
|
-
taalApiKey,
|
|
5594
|
-
devKeys: JSON.parse(DEV_KEYS) as Record<string, string>,
|
|
5595
|
-
mySQLConnection
|
|
5596
|
-
};
|
|
5597
|
-
}
|
|
5598
|
-
static async createWallet(args: SetupWalletArgs): Promise<SetupWallet> {
|
|
5599
|
-
const chain = args.env.chain;
|
|
5600
|
-
args.rootKeyHex ||= args.env.devKeys[args.env.identityKey];
|
|
5601
|
-
const rootKey = PrivateKey.fromHex(args.rootKeyHex);
|
|
5602
|
-
const identityKey = rootKey.toPublicKey().toString();
|
|
5603
|
-
const keyDeriver = new KeyDeriver(rootKey);
|
|
5604
|
-
const storage = new WalletStorageManager(identityKey, args.active, args.backups);
|
|
5605
|
-
if (storage.stores.length > 0)
|
|
5606
|
-
await storage.makeAvailable();
|
|
5607
|
-
const serviceOptions = Services.createDefaultOptions(chain);
|
|
5608
|
-
serviceOptions.taalApiKey = args.env.taalApiKey;
|
|
5609
|
-
const services = new Services(chain);
|
|
5610
|
-
const monopts = Monitor.createDefaultWalletMonitorOptions(chain, storage, services);
|
|
5611
|
-
const monitor = new Monitor(monopts);
|
|
5612
|
-
monitor.addDefaultTasks();
|
|
5613
|
-
let privilegedKeyManager: sdk.PrivilegedKeyManager | undefined = undefined;
|
|
5614
|
-
if (args.privKeyHex) {
|
|
5615
|
-
const privKey = PrivateKey.fromString(args.privKeyHex);
|
|
5616
|
-
privilegedKeyManager = new sdk.PrivilegedKeyManager(async () => privKey);
|
|
5617
|
-
}
|
|
5618
|
-
const wallet = new Wallet({
|
|
5619
|
-
chain,
|
|
5620
|
-
keyDeriver,
|
|
5621
|
-
storage,
|
|
5622
|
-
services,
|
|
5623
|
-
monitor,
|
|
5624
|
-
privilegedKeyManager
|
|
5625
|
-
});
|
|
5626
|
-
const r: SetupWallet = {
|
|
5627
|
-
rootKey,
|
|
5628
|
-
identityKey,
|
|
5629
|
-
keyDeriver,
|
|
5630
|
-
chain,
|
|
5631
|
-
storage,
|
|
5632
|
-
services,
|
|
5633
|
-
monitor,
|
|
5634
|
-
wallet
|
|
5635
|
-
};
|
|
5636
|
-
return r;
|
|
5637
|
-
}
|
|
5638
|
-
static async createWalletClient(args: SetupWalletClientArgs): Promise<SetupWalletClient> {
|
|
5639
|
-
const wo = await SetupClient.createWallet(args);
|
|
5640
|
-
const endpointUrl = args.endpointUrl ||
|
|
5641
|
-
`https://${args.env.chain !== "main" ? "staging-" : ""}storage.babbage.systems`;
|
|
5642
|
-
const client = new StorageClient(wo.wallet, endpointUrl);
|
|
5643
|
-
await wo.storage.addWalletStorageProvider(client);
|
|
5644
|
-
await wo.storage.makeAvailable();
|
|
5645
|
-
return {
|
|
5646
|
-
...wo,
|
|
5647
|
-
endpointUrl
|
|
5648
|
-
};
|
|
5649
|
-
}
|
|
5650
|
-
static getKeyPair(priv?: string | PrivateKey): KeyPairAddress {
|
|
5651
|
-
if (priv === undefined)
|
|
5652
|
-
priv = PrivateKey.fromRandom();
|
|
5653
|
-
else if (typeof priv === "string")
|
|
5654
|
-
priv = new PrivateKey(priv, "hex");
|
|
5655
|
-
const pub = PublicKey.fromPrivateKey(priv);
|
|
5656
|
-
const address = pub.toAddress();
|
|
5657
|
-
return { privateKey: priv, publicKey: pub, address };
|
|
5658
|
-
}
|
|
5659
|
-
static getLockP2PKH(address: string): LockingScript {
|
|
5660
|
-
const p2pkh = new P2PKH();
|
|
5661
|
-
const lock = p2pkh.lock(address);
|
|
5662
|
-
return lock;
|
|
5663
|
-
}
|
|
5664
|
-
static getUnlockP2PKH(priv: PrivateKey, satoshis: number): sdk.ScriptTemplateUnlock {
|
|
5665
|
-
const p2pkh = new P2PKH();
|
|
5666
|
-
const lock = SetupClient.getLockP2PKH(SetupClient.getKeyPair(priv).address);
|
|
5667
|
-
const unlock = p2pkh.unlock(priv, "all", false, satoshis, lock);
|
|
5668
|
-
return unlock;
|
|
5669
|
-
}
|
|
5670
|
-
static createP2PKHOutputs(outputs: {
|
|
5671
|
-
address: string;
|
|
5672
|
-
satoshis: number;
|
|
5673
|
-
outputDescription?: string;
|
|
5674
|
-
basket?: string;
|
|
5675
|
-
tags?: string[];
|
|
5676
|
-
}[]): CreateActionOutput[] {
|
|
5677
|
-
const os: CreateActionOutput[] = [];
|
|
5678
|
-
const count = outputs.length;
|
|
5679
|
-
for (let i = 0; i < count; i++) {
|
|
5680
|
-
const o = outputs[i];
|
|
5681
|
-
os.push({
|
|
5682
|
-
basket: o.basket,
|
|
5683
|
-
tags: o.tags,
|
|
5684
|
-
satoshis: o.satoshis,
|
|
5685
|
-
lockingScript: SetupClient.getLockP2PKH(o.address).toHex(),
|
|
5686
|
-
outputDescription: o.outputDescription || `p2pkh ${i}`
|
|
5687
|
-
});
|
|
5688
|
-
}
|
|
5689
|
-
return os;
|
|
5690
|
-
}
|
|
5691
|
-
static async createP2PKHOutputsAction(wallet: WalletInterface, outputs: {
|
|
5692
|
-
address: string;
|
|
5693
|
-
satoshis: number;
|
|
5694
|
-
outputDescription?: string;
|
|
5695
|
-
basket?: string;
|
|
5696
|
-
tags?: string[];
|
|
5697
|
-
}[], options?: CreateActionOptions): Promise<{
|
|
5698
|
-
cr: CreateActionResult;
|
|
5699
|
-
outpoints: string[] | undefined;
|
|
5700
|
-
}> {
|
|
5701
|
-
const os = SetupClient.createP2PKHOutputs(outputs);
|
|
5702
|
-
const createArgs: CreateActionArgs = {
|
|
5703
|
-
description: `createP2PKHOutputs`,
|
|
5704
|
-
outputs: os,
|
|
5705
|
-
options: {
|
|
5706
|
-
...options,
|
|
5707
|
-
randomizeOutputs: false
|
|
5708
|
-
}
|
|
5709
|
-
};
|
|
5710
|
-
const cr = await wallet.createAction(createArgs);
|
|
5711
|
-
let outpoints: string[] | undefined;
|
|
5712
|
-
if (cr.txid) {
|
|
5713
|
-
outpoints = os.map((o, i) => `${cr.txid}.${i}`);
|
|
5714
|
-
}
|
|
5715
|
-
return { cr, outpoints };
|
|
5716
|
-
}
|
|
5717
|
-
static async fundWalletFromP2PKHOutpoints(wallet: WalletInterface, outpoints: string[], p2pkhKey: KeyPairAddress, inputBEEF?: BEEF) {
|
|
5718
|
-
}
|
|
5719
|
-
}
|
|
5720
|
-
```
|
|
5721
|
-
|
|
5722
|
-
See also: [Chain](./client.md#type-chain), [KeyPairAddress](./setup.md#interface-keypairaddress), [Monitor](./monitor.md#class-monitor), [PrivilegedKeyManager](./client.md#class-privilegedkeymanager), [ScriptTemplateUnlock](./client.md#interface-scripttemplateunlock), [Services](./services.md#class-services), [Setup](./setup.md#class-setup), [SetupEnv](./setup.md#interface-setupenv), [SetupWallet](./setup.md#interface-setupwallet), [SetupWalletArgs](./setup.md#interface-setupwalletargs), [SetupWalletClient](./setup.md#interface-setupwalletclient), [SetupWalletClientArgs](./setup.md#interface-setupwalletclientargs), [StorageClient](./storage.md#class-storageclient), [WERR_INVALID_OPERATION](./client.md#class-werr_invalid_operation), [Wallet](./client.md#class-wallet), [WalletStorageManager](./storage.md#class-walletstoragemanager), [createAction](./storage.md#function-createaction), [verifyTruthy](./client.md#function-verifytruthy)
|
|
5723
|
-
|
|
5724
|
-
###### Method createWallet
|
|
5725
|
-
|
|
5726
|
-
Create a `Wallet`. Storage can optionally be provided or configured later.
|
|
5727
|
-
|
|
5728
|
-
The following components are configured: KeyDeriver, WalletStorageManager, WalletService, WalletStorage.
|
|
5729
|
-
Optionally, PrivilegedKeyManager is also configured.
|
|
5730
|
-
|
|
5731
|
-
```ts
|
|
5732
|
-
static async createWallet(args: SetupWalletArgs): Promise<SetupWallet> {
|
|
5733
|
-
const chain = args.env.chain;
|
|
5734
|
-
args.rootKeyHex ||= args.env.devKeys[args.env.identityKey];
|
|
5735
|
-
const rootKey = PrivateKey.fromHex(args.rootKeyHex);
|
|
5736
|
-
const identityKey = rootKey.toPublicKey().toString();
|
|
5737
|
-
const keyDeriver = new KeyDeriver(rootKey);
|
|
5738
|
-
const storage = new WalletStorageManager(identityKey, args.active, args.backups);
|
|
5739
|
-
if (storage.stores.length > 0)
|
|
5740
|
-
await storage.makeAvailable();
|
|
5741
|
-
const serviceOptions = Services.createDefaultOptions(chain);
|
|
5742
|
-
serviceOptions.taalApiKey = args.env.taalApiKey;
|
|
5743
|
-
const services = new Services(chain);
|
|
5744
|
-
const monopts = Monitor.createDefaultWalletMonitorOptions(chain, storage, services);
|
|
5745
|
-
const monitor = new Monitor(monopts);
|
|
5746
|
-
monitor.addDefaultTasks();
|
|
5747
|
-
let privilegedKeyManager: sdk.PrivilegedKeyManager | undefined = undefined;
|
|
5748
|
-
if (args.privKeyHex) {
|
|
5749
|
-
const privKey = PrivateKey.fromString(args.privKeyHex);
|
|
5750
|
-
privilegedKeyManager = new sdk.PrivilegedKeyManager(async () => privKey);
|
|
5751
|
-
}
|
|
5752
|
-
const wallet = new Wallet({
|
|
5753
|
-
chain,
|
|
5754
|
-
keyDeriver,
|
|
5755
|
-
storage,
|
|
5756
|
-
services,
|
|
5757
|
-
monitor,
|
|
5758
|
-
privilegedKeyManager
|
|
5759
|
-
});
|
|
5760
|
-
const r: SetupWallet = {
|
|
5761
|
-
rootKey,
|
|
5762
|
-
identityKey,
|
|
5763
|
-
keyDeriver,
|
|
5764
|
-
chain,
|
|
5765
|
-
storage,
|
|
5766
|
-
services,
|
|
5767
|
-
monitor,
|
|
5768
|
-
wallet
|
|
5769
|
-
};
|
|
5770
|
-
return r;
|
|
5771
|
-
}
|
|
5772
|
-
```
|
|
5773
|
-
See also: [Monitor](./monitor.md#class-monitor), [PrivilegedKeyManager](./client.md#class-privilegedkeymanager), [Services](./services.md#class-services), [SetupWallet](./setup.md#interface-setupwallet), [SetupWalletArgs](./setup.md#interface-setupwalletargs), [Wallet](./client.md#class-wallet), [WalletStorageManager](./storage.md#class-walletstoragemanager)
|
|
5774
|
-
|
|
5775
|
-
###### Method getEnv
|
|
5776
|
-
|
|
5777
|
-
Reads a .env file of the format created by `makeEnv`.
|
|
5778
|
-
|
|
5779
|
-
Returns values for designated `chain`.
|
|
5780
|
-
|
|
5781
|
-
Access private keys through the `devKeys` object: `devKeys[identityKey]`
|
|
5782
|
-
|
|
5783
|
-
```ts
|
|
5784
|
-
static getEnv(chain: sdk.Chain): SetupEnv {
|
|
5785
|
-
const identityKey = chain === "main"
|
|
5786
|
-
? process.env.MY_MAIN_IDENTITY
|
|
5787
|
-
: process.env.MY_TEST_IDENTITY;
|
|
5788
|
-
const identityKey2 = chain === "main"
|
|
5789
|
-
? process.env.MY_MAIN_IDENTITY2
|
|
5790
|
-
: process.env.MY_TEST_IDENTITY2;
|
|
5791
|
-
const filePath = chain === "main"
|
|
5792
|
-
? process.env.MY_MAIN_FILEPATH
|
|
5793
|
-
: process.env.MY_TEST_FILEPATH;
|
|
5794
|
-
const DEV_KEYS = process.env.DEV_KEYS || "{}";
|
|
5795
|
-
const mySQLConnection = process.env.MYSQL_CONNECTION || "{}";
|
|
5796
|
-
const taalApiKey = verifyTruthy(chain === "main"
|
|
5797
|
-
? process.env.MAIN_TAAL_API_KEY
|
|
5798
|
-
: process.env.TEST_TAAL_API_KEY, `.env value for '${chain.toUpperCase()}_TAAL_API_KEY' is required.`);
|
|
5799
|
-
if (!identityKey || !identityKey2)
|
|
5800
|
-
throw new sdk.WERR_INVALID_OPERATION(".env is not a valid SetupEnv configuration.");
|
|
5801
|
-
return {
|
|
5802
|
-
chain,
|
|
5803
|
-
identityKey,
|
|
5804
|
-
identityKey2,
|
|
5805
|
-
filePath,
|
|
5806
|
-
taalApiKey,
|
|
5807
|
-
devKeys: JSON.parse(DEV_KEYS) as Record<string, string>,
|
|
5808
|
-
mySQLConnection
|
|
5809
|
-
};
|
|
5810
|
-
}
|
|
5811
|
-
```
|
|
5812
|
-
See also: [Chain](./client.md#type-chain), [SetupEnv](./setup.md#interface-setupenv), [WERR_INVALID_OPERATION](./client.md#class-werr_invalid_operation), [verifyTruthy](./client.md#function-verifytruthy)
|
|
5813
|
-
|
|
5814
|
-
Returns
|
|
5815
|
-
|
|
5816
|
-
with configuration environment secrets used by `Setup` functions.
|
|
5817
|
-
|
|
5818
|
-
Argument Details
|
|
5819
|
-
|
|
5820
|
-
+ **chain**
|
|
5821
|
-
+ Which chain to use: 'test' or 'main'
|
|
5822
|
-
|
|
5823
|
-
###### Method makeEnv
|
|
5824
|
-
|
|
5825
|
-
Creates content for .env file with some private keys, identity keys, sample API keys, and sample MySQL connection string.
|
|
5826
|
-
|
|
5827
|
-
Two new, random private keys are generated each time, with their associated public identity keys.
|
|
5828
|
-
|
|
5829
|
-
Loading secrets from a .env file is intended only for experimentation and getting started.
|
|
5830
|
-
Private keys should never be included directly in your source code.
|
|
5831
|
-
|
|
5832
|
-
```ts
|
|
5833
|
-
static makeEnv(): string {
|
|
5834
|
-
const testPrivKey1 = PrivateKey.fromRandom();
|
|
5835
|
-
const testIdentityKey1 = testPrivKey1.toPublicKey().toString();
|
|
5836
|
-
const testPrivKey2 = PrivateKey.fromRandom();
|
|
5837
|
-
const testIdentityKey2 = testPrivKey2.toPublicKey().toString();
|
|
5838
|
-
const mainPrivKey1 = PrivateKey.fromRandom();
|
|
5839
|
-
const mainIdentityKey1 = mainPrivKey1.toPublicKey().toString();
|
|
5840
|
-
const mainPrivKey2 = PrivateKey.fromRandom();
|
|
5841
|
-
const mainIdentityKey2 = mainPrivKey2.toPublicKey().toString();
|
|
5842
|
-
const log = `
|
|
5843
|
-
# .env file template for working with wallet-toolbox Setup functions.
|
|
5844
|
-
MY_TEST_IDENTITY = '${testIdentityKey1}'
|
|
5845
|
-
MY_TEST_IDENTITY2 = '${testIdentityKey2}'
|
|
5846
|
-
MY_MAIN_IDENTITY = '${mainIdentityKey1}'
|
|
5847
|
-
MY_MAIN_IDENTITY2 = '${mainIdentityKey2}'
|
|
5848
|
-
MAIN_TAAL_API_KEY='mainnet_9596de07e92300c6287e4393594ae39c'
|
|
5849
|
-
TEST_TAAL_API_KEY='testnet_0e6cf72133b43ea2d7861da2a38684e3'
|
|
5850
|
-
MYSQL_CONNECTION='{"port":3306,"host":"127.0.0.1","user":"root","password":"your_password","database":"your_database", "timezone": "Z"}'
|
|
5851
|
-
DEV_KEYS = '{
|
|
5852
|
-
"${testIdentityKey1}": "${testPrivKey1.toString()}",
|
|
5853
|
-
"${testIdentityKey2}": "${testPrivKey2.toString()}",
|
|
5854
|
-
"${mainIdentityKey1}": "${mainPrivKey1.toString()}",
|
|
5855
|
-
"${mainIdentityKey2}": "${mainPrivKey2.toString()}"
|
|
5856
|
-
}'
|
|
5857
|
-
`;
|
|
5858
|
-
console.log(log);
|
|
5859
|
-
return log;
|
|
5860
|
-
}
|
|
5861
|
-
```
|
|
5862
|
-
See also: [Setup](./setup.md#class-setup)
|
|
5863
|
-
|
|
5864
|
-
###### Method noEnv
|
|
5865
|
-
|
|
5866
|
-
```ts
|
|
5867
|
-
static noEnv(chain: sdk.Chain): boolean
|
|
5868
|
-
```
|
|
5869
|
-
See also: [Chain](./client.md#type-chain)
|
|
5870
|
-
|
|
5871
|
-
Returns
|
|
5872
|
-
|
|
5873
|
-
true if .env is not valid for chain
|
|
5874
|
-
|
|
5875
|
-
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
|
|
5876
|
-
|
|
5877
5203
|
---
|
|
5878
5204
|
##### Class: StorageClient
|
|
5879
5205
|
|