@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/src/index.all.ts
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
export * as sdk from './sdk/index'
|
|
2
2
|
export * from './utility/index.all'
|
|
3
3
|
export * from './Wallet'
|
|
4
|
-
export
|
|
4
|
+
export {
|
|
5
|
+
SetupClient,
|
|
6
|
+
KeyPairAddress,
|
|
7
|
+
SetupEnv,
|
|
8
|
+
SetupWalletArgs,
|
|
9
|
+
SetupWallet,
|
|
10
|
+
SetupWalletClient,
|
|
11
|
+
SetupWalletClientArgs
|
|
12
|
+
} from './SetupClient'
|
|
5
13
|
export * from './Setup'
|
|
6
14
|
export * from './signer/WalletSigner'
|
|
7
15
|
export * from './storage/index.all'
|
package/src/sdk/types.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { Transaction, UnlockingScript } from '@bsv/sdk'
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Identifies a unique transaction output by its `txid` and index `vout`
|
|
3
5
|
*/
|
|
@@ -113,3 +115,8 @@ export interface EntityTimeStamp {
|
|
|
113
115
|
created_at: Date
|
|
114
116
|
updated_at: Date
|
|
115
117
|
}
|
|
118
|
+
|
|
119
|
+
export interface ScriptTemplateUnlock {
|
|
120
|
+
sign: (tx: Transaction, inputIndex: number) => Promise<UnlockingScript>
|
|
121
|
+
estimateLength: (tx: Transaction, inputIndex: number) => Promise<number>
|
|
122
|
+
}
|
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
} from '../index.client'
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
|
-
* The `
|
|
24
|
+
* The `WalletStorageManager` class delivers authentication checking storage access to the wallet.
|
|
25
25
|
*
|
|
26
26
|
* If manages multiple `StorageBase` derived storage services: one actice, the rest as backups.
|
|
27
27
|
*
|
|
@@ -45,8 +45,10 @@ export async function listOutputs(
|
|
|
45
45
|
partial: { userId, name: vargs.basket },
|
|
46
46
|
trx
|
|
47
47
|
})
|
|
48
|
-
if (baskets.length !== 1)
|
|
49
|
-
|
|
48
|
+
if (baskets.length !== 1) {
|
|
49
|
+
// If basket does not exist, result is no outputs.
|
|
50
|
+
return r
|
|
51
|
+
}
|
|
50
52
|
const basket = baskets[0]
|
|
51
53
|
basketId = basket.basketId!
|
|
52
54
|
basketsById[basketId!] = basket
|
|
@@ -18,6 +18,10 @@ export interface ScriptTemplateParamsSABPPP {
|
|
|
18
18
|
|
|
19
19
|
export const brc29ProtocolID: WalletProtocol = [2, '3241645161d8']
|
|
20
20
|
|
|
21
|
+
/**
|
|
22
|
+
* Simple Authenticated BSV P2PKH Payment Protocol
|
|
23
|
+
* https://brc.dev/29
|
|
24
|
+
*/
|
|
21
25
|
export class ScriptTemplateSABPPP implements ScriptTemplate {
|
|
22
26
|
p2pkh: P2PKH
|
|
23
27
|
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { InternalizeActionArgs, PrivateKey, Utils } from '@bsv/sdk'
|
|
2
2
|
import { Setup } from '../../src'
|
|
3
3
|
|
|
4
|
-
describe
|
|
4
|
+
describe('examples README tests', () => {
|
|
5
5
|
jest.setTimeout(99999999)
|
|
6
6
|
|
|
7
|
-
it('0', async () => {
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
it('0 makeEnv', async () => {
|
|
8
|
+
const envString = Setup.makeEnv()
|
|
9
|
+
})
|
|
10
|
+
|
|
11
|
+
it('1 internalize wallet payment', async () => {
|
|
12
|
+
const env = Setup.getEnv('test')
|
|
12
13
|
|
|
13
14
|
const { wallet } = await Setup.createSQLiteWallet({
|
|
15
|
+
env,
|
|
14
16
|
filePath: './myTestWallet.sqlite',
|
|
15
|
-
databaseName: 'myTestWallet'
|
|
16
|
-
chain: 'test',
|
|
17
|
-
rootKeyHex
|
|
17
|
+
databaseName: 'myTestWallet'
|
|
18
18
|
})
|
|
19
19
|
|
|
20
20
|
// Obtain a Wallet Payment for your new wallet from a testnet funding faucet.
|
|
@@ -143,7 +143,7 @@ describe('listOutputs test', () => {
|
|
|
143
143
|
}
|
|
144
144
|
})
|
|
145
145
|
|
|
146
|
-
test('
|
|
146
|
+
test('2a default', async () => {
|
|
147
147
|
for (const { wallet } of ctxs) {
|
|
148
148
|
{
|
|
149
149
|
let log = `\n${testName()}\n`
|
|
@@ -166,7 +166,7 @@ describe('listOutputs test', () => {
|
|
|
166
166
|
}
|
|
167
167
|
})
|
|
168
168
|
|
|
169
|
-
test('
|
|
169
|
+
test('2b default with originators', async () => {
|
|
170
170
|
for (const { wallet } of ctxs) {
|
|
171
171
|
{
|
|
172
172
|
let log = `\n${testName()}\n`
|
|
@@ -260,18 +260,12 @@ describe('listOutputs test', () => {
|
|
|
260
260
|
|
|
261
261
|
test('6_non-existent basket', async () => {
|
|
262
262
|
for (const { wallet } of ctxs) {
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
basket: 'non-existent-basket',
|
|
267
|
-
tags: ['babbage_action_originator projectbabbage.com'],
|
|
268
|
-
includeTags: true
|
|
269
|
-
}
|
|
270
|
-
await expectToThrowWERR(
|
|
271
|
-
sdk.WERR_INVALID_PARAMETER,
|
|
272
|
-
async () => await wallet.listOutputs(args)
|
|
273
|
-
)
|
|
263
|
+
// non-existent basket should return zero results.
|
|
264
|
+
const args: ListOutputsArgs = {
|
|
265
|
+
basket: 'admin foo'
|
|
274
266
|
}
|
|
267
|
+
const r = await wallet.listOutputs(args)
|
|
268
|
+
expect(r.totalOutputs === 0)
|
|
275
269
|
}
|
|
276
270
|
})
|
|
277
271
|
|
package/ts2md.json
CHANGED
package/tsconfig.all.json
CHANGED
package/LICENSE.txt
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
Open BSV License version 4
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2023 BSV Blockchain Association ("Bitcoin Association")
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
1 - The above copyright notice and this permission notice shall be included in
|
|
13
|
-
all copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
2 - The Software, and any software that is derived from the Software or parts thereof,
|
|
16
|
-
can only be used on the Bitcoin SV blockchains. The Bitcoin SV blockchains are defined,
|
|
17
|
-
for purposes of this license, as the Bitcoin blockchain containing block height #556767
|
|
18
|
-
with the hash "000000000000000001d956714215d96ffc00e0afda4cd0a96c96f8d802b1662b" and
|
|
19
|
-
that contains the longest persistent chain of blocks accepted by this Software and which are valid under the rules set forth in the Bitcoin white paper (S. Nakamoto, Bitcoin: A Peer-to-Peer Electronic Cash System, posted online October 2008) and the latest version of this Software available in this repository or another repository designated by Bitcoin Association,
|
|
20
|
-
as well as the test blockchains that contain the longest persistent chains of blocks accepted by this Software and which are valid under the rules set forth in the Bitcoin whitepaper (S. Nakamoto, Bitcoin: A Peer-to-Peer Electronic Cash System, posted online October 2008) and the latest version of this Software available in this repository, or another repository designated by Bitcoin Association
|
|
21
|
-
|
|
22
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
23
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
24
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
25
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
26
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
27
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
28
|
-
THE SOFTWARE.
|
package/dev.sqlite3
DELETED
|
File without changes
|