Skip to content

Commit b736940

Browse files
committed
...
1 parent a174cef commit b736940

File tree

13 files changed

+9391
-2201
lines changed

13 files changed

+9391
-2201
lines changed

docs/client.md

Lines changed: 213 additions & 151 deletions
Large diffs are not rendered by default.

docs/services.md

Lines changed: 63 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](
130130
| --- |
131131
| [ServiceCollection](#class-servicecollection) |
132132
| [Services](#class-services) |
133+
| [WhatsOnChain](#class-whatsonchain) |
133134

134135
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
135136

@@ -173,6 +174,7 @@ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](
173174
export class Services implements sdk.WalletServices {
174175
static createDefaultOptions(chain: sdk.Chain): sdk.WalletServicesOptions
175176
options: sdk.WalletServicesOptions;
177+
whatsonchain: WhatsOnChain;
176178
getMerklePathServices: ServiceCollection<sdk.GetMerklePathService>;
177179
getRawTxServices: ServiceCollection<sdk.GetRawTxService>;
178180
postTxsServices: ServiceCollection<sdk.PostTxsService>;
@@ -204,7 +206,7 @@ export class Services implements sdk.WalletServices {
204206
}
205207
```
206208

207-
See also: [BlockHeader](./client.md#interface-blockheader), [Chain](./client.md#type-chain), [FiatExchangeRates](./client.md#interface-fiatexchangerates), [GetMerklePathResult](./client.md#interface-getmerklepathresult), [GetMerklePathService](./client.md#type-getmerklepathservice), [GetRawTxResult](./client.md#interface-getrawtxresult), [GetRawTxService](./client.md#type-getrawtxservice), [GetUtxoStatusOutputFormat](./client.md#type-getutxostatusoutputformat), [GetUtxoStatusResult](./client.md#interface-getutxostatusresult), [GetUtxoStatusService](./client.md#type-getutxostatusservice), [PostBeefResult](./client.md#interface-postbeefresult), [PostBeefService](./client.md#type-postbeefservice), [PostTxsResult](./client.md#interface-posttxsresult), [PostTxsService](./client.md#type-posttxsservice), [ServiceCollection](./services.md#class-servicecollection), [UpdateFiatExchangeRateService](./client.md#type-updatefiatexchangerateservice), [WalletServices](./client.md#interface-walletservices), [WalletServicesOptions](./client.md#interface-walletservicesoptions)
209+
See also: [BlockHeader](./client.md#interface-blockheader), [Chain](./client.md#type-chain), [FiatExchangeRates](./client.md#interface-fiatexchangerates), [GetMerklePathResult](./client.md#interface-getmerklepathresult), [GetMerklePathService](./client.md#type-getmerklepathservice), [GetRawTxResult](./client.md#interface-getrawtxresult), [GetRawTxService](./client.md#type-getrawtxservice), [GetUtxoStatusOutputFormat](./client.md#type-getutxostatusoutputformat), [GetUtxoStatusResult](./client.md#interface-getutxostatusresult), [GetUtxoStatusService](./client.md#type-getutxostatusservice), [PostBeefResult](./client.md#interface-postbeefresult), [PostBeefService](./client.md#type-postbeefservice), [PostTxsResult](./client.md#interface-posttxsresult), [PostTxsService](./client.md#type-posttxsservice), [ServiceCollection](./services.md#class-servicecollection), [UpdateFiatExchangeRateService](./client.md#type-updatefiatexchangerateservice), [WalletServices](./client.md#interface-walletservices), [WalletServicesOptions](./client.md#interface-walletservicesoptions), [WhatsOnChain](./services.md#class-whatsonchain)
208210

209211
###### Method postTxs
210212

@@ -220,104 +222,118 @@ See also: [PostTxsResult](./client.md#interface-posttxsresult)
220222
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
221223

222224
---
223-
#### Functions
225+
##### Class: WhatsOnChain
224226

225-
| | |
226-
| --- | --- |
227-
| [createDefaultWalletServicesOptions](#function-createdefaultwalletservicesoptions) | [makePostBeefToTaalARC](#function-makepostbeeftotaalarc) |
228-
| [getExchangeRatesIo](#function-getexchangeratesio) | [makePostTxsToTaalARC](#function-makeposttxstotaalarc) |
229-
| [getMerklePathFromTaalARC](#function-getmerklepathfromtaalarc) | [postBeefToArcMiner](#function-postbeeftoarcminer) |
230-
| [getMerklePathFromWhatsOnChainTsc](#function-getmerklepathfromwhatsonchaintsc) | [postBeefToTaalArcMiner](#function-postbeeftotaalarcminer) |
231-
| [getRawTxFromWhatsOnChain](#function-getrawtxfromwhatsonchain) | [postTxsToTaalArcMiner](#function-posttxstotaalarcminer) |
232-
| [getTaalArcServiceConfig](#function-gettaalarcserviceconfig) | [toBinaryBaseBlockHeader](#function-tobinarybaseblockheader) |
233-
| [getUtxoStatusFromWhatsOnChain](#function-getutxostatusfromwhatsonchain) | [updateBsvExchangeRate](#function-updatebsvexchangerate) |
234-
| [makeErrorResult](#function-makeerrorresult) | [updateChaintracksFiatExchangeRates](#function-updatechaintracksfiatexchangerates) |
235-
| [makeGetMerklePathFromTaalARC](#function-makegetmerklepathfromtaalarc) | [updateExchangeratesapi](#function-updateexchangeratesapi) |
236-
| [makePostBeefResult](#function-makepostbeefresult) | [validateScriptHash](#function-validatescripthash) |
227+
```ts
228+
export class WhatsOnChain extends SdkWhatsOnChain {
229+
constructor(chain: sdk.Chain = "main", config: WhatsOnChainConfig = {})
230+
async getTxPropagation(txid: string): Promise<number>
231+
async getRawTx(txid: string): Promise<string | undefined>
232+
async getRawTxResult(txid: string): Promise<sdk.GetRawTxResult>
233+
async postRawTx(rawTx: HexString): Promise<string>
234+
async getMerklePath(txid: string, services: sdk.WalletServices): Promise<sdk.GetMerklePathResult>
235+
async updateBsvExchangeRate(rate?: sdk.BsvExchangeRate, updateMsecs?: number): Promise<sdk.BsvExchangeRate>
236+
async getUtxoStatus(output: string, outputFormat?: sdk.GetUtxoStatusOutputFormat): Promise<sdk.GetUtxoStatusResult>
237+
}
238+
```
237239

238-
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
240+
See also: [BsvExchangeRate](./client.md#interface-bsvexchangerate), [Chain](./client.md#type-chain), [GetMerklePathResult](./client.md#interface-getmerklepathresult), [GetRawTxResult](./client.md#interface-getrawtxresult), [GetUtxoStatusOutputFormat](./client.md#type-getutxostatusoutputformat), [GetUtxoStatusResult](./client.md#interface-getutxostatusresult), [WalletServices](./client.md#interface-walletservices)
239241

240-
---
242+
###### Method getRawTx
241243

242-
##### Function: createDefaultWalletServicesOptions
244+
May return undefined for unmined transactions that are in the mempool.
243245

244246
```ts
245-
export function createDefaultWalletServicesOptions(chain: sdk.Chain): sdk.WalletServicesOptions
247+
async getRawTx(txid: string): Promise<string | undefined>
246248
```
247249

248-
See also: [Chain](./client.md#type-chain), [WalletServicesOptions](./client.md#interface-walletservicesoptions)
250+
Returns
249251

250-
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
252+
raw transaction as hex string or undefined if txid not found in mined block.
251253

252-
---
253-
##### Function: getExchangeRatesIo
254+
###### Method getTxPropagation
255+
256+
2025-02-16 throwing internal server error 500.
254257

255258
```ts
256-
export async function getExchangeRatesIo(key: string): Promise<ExchangeRatesIoApi>
259+
async getTxPropagation(txid: string): Promise<number>
257260
```
258261

259-
See also: [ExchangeRatesIoApi](./services.md#interface-exchangeratesioapi)
260-
261-
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
262-
263-
---
264-
##### Function: getMerklePathFromTaalARC
262+
###### Method postRawTx
265263

266264
```ts
267-
export async function getMerklePathFromTaalARC(txid: string, config: ArcServiceConfig, services: sdk.WalletServices): Promise<sdk.GetMerklePathResult>
265+
async postRawTx(rawTx: HexString): Promise<string>
268266
```
269267

270-
See also: [ArcServiceConfig](./services.md#interface-arcserviceconfig), [GetMerklePathResult](./client.md#interface-getmerklepathresult), [WalletServices](./client.md#interface-walletservices)
268+
Returns
269+
270+
txid returned by transaction processor of transaction broadcast
271+
272+
Argument Details
273+
274+
+ **rawTx**
275+
+ raw transaction to broadcast as hex string
271276

272277
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
273278

274279
---
275-
##### Function: getMerklePathFromWhatsOnChainTsc
280+
#### Functions
281+
282+
| | |
283+
| --- | --- |
284+
| [createDefaultWalletServicesOptions](#function-createdefaultwalletservicesoptions) | [makePostTxsToTaalARC](#function-makeposttxstotaalarc) |
285+
| [getExchangeRatesIo](#function-getexchangeratesio) | [postBeefToArcMiner](#function-postbeeftoarcminer) |
286+
| [getMerklePathFromTaalARC](#function-getmerklepathfromtaalarc) | [postBeefToTaalArcMiner](#function-postbeeftotaalarcminer) |
287+
| [getTaalArcServiceConfig](#function-gettaalarcserviceconfig) | [postTxsToTaalArcMiner](#function-posttxstotaalarcminer) |
288+
| [makeErrorResult](#function-makeerrorresult) | [toBinaryBaseBlockHeader](#function-tobinarybaseblockheader) |
289+
| [makeGetMerklePathFromTaalARC](#function-makegetmerklepathfromtaalarc) | [updateChaintracksFiatExchangeRates](#function-updatechaintracksfiatexchangerates) |
290+
| [makePostBeefResult](#function-makepostbeefresult) | [updateExchangeratesapi](#function-updateexchangeratesapi) |
291+
| [makePostBeefToTaalARC](#function-makepostbeeftotaalarc) | [validateScriptHash](#function-validatescripthash) |
276292

277-
WhatOnChain.com has their own "hash/pos/R/L" proof format and a more TSC compliant proof format.
293+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
294+
295+
---
278296

279-
The "/proof/tsc" endpoint is much closer to the TSC specification. It provides "index" directly and each node is just the provided hash value.
280-
The "targetType" is unspecified and thus defaults to block header hash, requiring a Chaintracks lookup to get the merkleRoot...
281-
Duplicate hash values are provided in full instead of being replaced by "*".
297+
##### Function: createDefaultWalletServicesOptions
282298

283299
```ts
284-
export async function getMerklePathFromWhatsOnChainTsc(txid: string, chain: sdk.Chain, services: sdk.WalletServices): Promise<sdk.GetMerklePathResult>
300+
export function createDefaultWalletServicesOptions(chain: sdk.Chain): sdk.WalletServicesOptions
285301
```
286302

287-
See also: [Chain](./client.md#type-chain), [GetMerklePathResult](./client.md#interface-getmerklepathresult), [WalletServices](./client.md#interface-walletservices)
303+
See also: [Chain](./client.md#type-chain), [WalletServicesOptions](./client.md#interface-walletservicesoptions)
288304

289305
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
290306

291307
---
292-
##### Function: getRawTxFromWhatsOnChain
308+
##### Function: getExchangeRatesIo
293309

294310
```ts
295-
export async function getRawTxFromWhatsOnChain(txid: string, chain: sdk.Chain): Promise<sdk.GetRawTxResult>
311+
export async function getExchangeRatesIo(key: string): Promise<ExchangeRatesIoApi>
296312
```
297313

298-
See also: [Chain](./client.md#type-chain), [GetRawTxResult](./client.md#interface-getrawtxresult)
314+
See also: [ExchangeRatesIoApi](./services.md#interface-exchangeratesioapi)
299315

300316
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
301317

302318
---
303-
##### Function: getTaalArcServiceConfig
319+
##### Function: getMerklePathFromTaalARC
304320

305321
```ts
306-
export function getTaalArcServiceConfig(chain: sdk.Chain, apiKey: string): ArcServiceConfig
322+
export async function getMerklePathFromTaalARC(txid: string, config: ArcServiceConfig, services: sdk.WalletServices): Promise<sdk.GetMerklePathResult>
307323
```
308324

309-
See also: [ArcServiceConfig](./services.md#interface-arcserviceconfig), [Chain](./client.md#type-chain)
325+
See also: [ArcServiceConfig](./services.md#interface-arcserviceconfig), [GetMerklePathResult](./client.md#interface-getmerklepathresult), [WalletServices](./client.md#interface-walletservices)
310326

311327
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
312328

313329
---
314-
##### Function: getUtxoStatusFromWhatsOnChain
330+
##### Function: getTaalArcServiceConfig
315331

316332
```ts
317-
export async function getUtxoStatusFromWhatsOnChain(output: string, chain: sdk.Chain, outputFormat?: sdk.GetUtxoStatusOutputFormat): Promise<sdk.GetUtxoStatusResult>
333+
export function getTaalArcServiceConfig(chain: sdk.Chain, apiKey: string): ArcServiceConfig
318334
```
319335

320-
See also: [Chain](./client.md#type-chain), [GetUtxoStatusOutputFormat](./client.md#type-getutxostatusoutputformat), [GetUtxoStatusResult](./client.md#interface-getutxostatusresult)
336+
See also: [ArcServiceConfig](./services.md#interface-arcserviceconfig), [Chain](./client.md#type-chain)
321337

322338
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
323339

@@ -444,17 +460,6 @@ Returns
444460

445461
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
446462

447-
---
448-
##### Function: updateBsvExchangeRate
449-
450-
```ts
451-
export async function updateBsvExchangeRate(rate?: sdk.BsvExchangeRate, updateMsecs?: number): Promise<sdk.BsvExchangeRate>
452-
```
453-
454-
See also: [BsvExchangeRate](./client.md#interface-bsvexchangerate)
455-
456-
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
457-
458463
---
459464
##### Function: updateChaintracksFiatExchangeRates
460465

docs/setup.md

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ export interface SetupEnv {
6060
chain: sdk.Chain;
6161
identityKey: string;
6262
identityKey2: string;
63+
filePath: string | undefined;
6364
taalApiKey: string;
6465
devKeys: Record<string, string>;
6566
mySQLConnection: string;
@@ -85,6 +86,14 @@ A map of public keys (identity keys, hex strings) to private keys (hex strings).
8586
devKeys: Record<string, string>
8687
```
8788

89+
###### Property filePath
90+
91+
Filepath to sqlite file to be used for identityKey wallet.
92+
93+
```ts
94+
filePath: string | undefined
95+
```
96+
8897
###### Property identityKey
8998

9099
The user's primary identity key (public key).
@@ -584,6 +593,9 @@ DEV_KEYS = '{
584593
const identityKey2 = chain === "main"
585594
? process.env.MY_MAIN_IDENTITY2
586595
: process.env.MY_TEST_IDENTITY2;
596+
const filePath = chain === "main"
597+
? process.env.MY_MAIN_FILEPATH
598+
: process.env.MY_TEST_FILEPATH;
587599
const DEV_KEYS = process.env.DEV_KEYS || "{}";
588600
const mySQLConnection = process.env.MYSQL_CONNECTION || "{}";
589601
const taalApiKey = verifyTruthy(chain === "main"
@@ -595,6 +607,7 @@ DEV_KEYS = '{
595607
chain,
596608
identityKey,
597609
identityKey2,
610+
filePath,
598611
taalApiKey,
599612
devKeys: JSON.parse(DEV_KEYS) as Record<string, string>,
600613
mySQLConnection
@@ -642,9 +655,8 @@ DEV_KEYS = '{
642655
}
643656
static async createWalletClient(args: SetupWalletClientArgs): Promise<SetupWalletClient> {
644657
const wo = await SetupClient.createWallet(args);
645-
if (wo.chain === "main")
646-
throw new sdk.WERR_INVALID_PARAMETER("chain", `'test' for now, 'main' is not yet supported.`);
647-
const endpointUrl = args.endpointUrl || "https://staging-dojo.babbage.systems";
658+
const endpointUrl = args.endpointUrl ||
659+
`https://${args.env.chain !== "main" ? "staging-" : ""}storage.babbage.systems`;
648660
const client = new StorageClient(wo.wallet, endpointUrl);
649661
await wo.storage.addWalletStorageProvider(client);
650662
await wo.storage.makeAvailable();
@@ -725,7 +737,7 @@ DEV_KEYS = '{
725737
}
726738
```
727739

728-
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), [WERR_INVALID_PARAMETER](./client.md#class-werr_invalid_parameter), [Wallet](./client.md#class-wallet), [WalletStorageManager](./storage.md#class-walletstoragemanager), [createAction](./storage.md#function-createaction), [verifyTruthy](./client.md#function-verifytruthy)
740+
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)
729741

730742
###### Method createWallet
731743

@@ -794,6 +806,9 @@ static getEnv(chain: sdk.Chain): SetupEnv {
794806
const identityKey2 = chain === "main"
795807
? process.env.MY_MAIN_IDENTITY2
796808
: process.env.MY_TEST_IDENTITY2;
809+
const filePath = chain === "main"
810+
? process.env.MY_MAIN_FILEPATH
811+
: process.env.MY_TEST_FILEPATH;
797812
const DEV_KEYS = process.env.DEV_KEYS || "{}";
798813
const mySQLConnection = process.env.MYSQL_CONNECTION || "{}";
799814
const taalApiKey = verifyTruthy(chain === "main"
@@ -805,6 +820,7 @@ static getEnv(chain: sdk.Chain): SetupEnv {
805820
chain,
806821
identityKey,
807822
identityKey2,
823+
filePath,
808824
taalApiKey,
809825
devKeys: JSON.parse(DEV_KEYS) as Record<string, string>,
810826
mySQLConnection

0 commit comments

Comments
 (0)