@xo-cash/engine 0.0.1-development.15965991683 → 0.1.0-next.17295903694
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/README.md +21 -18
- package/dist/index.d.mts +3282 -765
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +7821 -1815
- package/dist/index.mjs.map +1 -1
- package/package.json +17 -14
package/README.md
CHANGED
|
@@ -13,34 +13,37 @@ npm install @xo-cash/engine
|
|
|
13
13
|
### Basic Setup
|
|
14
14
|
|
|
15
15
|
```typescript
|
|
16
|
-
import { Engine } from '@xo-cash/engine';
|
|
17
|
-
import {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
// Initialize the engine with wallet seed and storage options
|
|
25
|
-
const engine = await Engine.create('your-wallet-seed', client, {
|
|
16
|
+
import { Engine, XO_SUPPORTED_NETWORKS } from '@xo-cash/engine';
|
|
17
|
+
import { StorageType } from '@xo-cash/state';
|
|
18
|
+
import { p2pkhTemplate } from '@xo-cash/templates';
|
|
19
|
+
|
|
20
|
+
// Create the engine for one account. It connects to the Electrum servers of the network itself.
|
|
21
|
+
const engine = await Engine.create('your BIP39 mnemonic', {
|
|
22
|
+
network: XO_SUPPORTED_NETWORKS.chipnet,
|
|
23
|
+
storageType: StorageType.SQLITE,
|
|
26
24
|
databasePath: './',
|
|
27
25
|
databaseFilename: 'XO',
|
|
28
|
-
defaultTemplateHubUrl: 'https://template-hub.example.com',
|
|
29
26
|
});
|
|
30
27
|
|
|
31
|
-
// Import a template
|
|
32
|
-
const templateIdentifier = await engine.importTemplate(
|
|
28
|
+
// Import a template. The result carries the template and its identifier.
|
|
29
|
+
const { templateIdentifier } = await engine.importTemplate(p2pkhTemplate);
|
|
33
30
|
|
|
34
|
-
//
|
|
35
|
-
const startingActions = await engine.
|
|
31
|
+
// Read the actions the template can start with.
|
|
32
|
+
const startingActions = (await engine.getTemplate(templateIdentifier))?.start ?? [];
|
|
36
33
|
|
|
37
|
-
// Create an invitation for
|
|
38
|
-
const
|
|
34
|
+
// Create an invitation for one of those actions.
|
|
35
|
+
const storedInvitation = await engine.createInvitation({
|
|
39
36
|
templateIdentifier,
|
|
40
|
-
actionIdentifier: '
|
|
37
|
+
actionIdentifier: 'requestSatoshis',
|
|
38
|
+
intent: startingActions.find((startingAction) => startingAction.action === 'requestSatoshis'),
|
|
41
39
|
});
|
|
40
|
+
|
|
41
|
+
// Stop the engine to close its Electrum connections and storage, and destroy its keys.
|
|
42
|
+
await engine.stop();
|
|
42
43
|
```
|
|
43
44
|
|
|
45
|
+
See `playground/examples/receive-satoshis.js` for a full flow that funds, signs, and executes an invitation.
|
|
46
|
+
|
|
44
47
|
## Links
|
|
45
48
|
|
|
46
49
|
- [Repository](https://gitlab.com/GeneralProtocols/xo/engine)
|