@bsv/wallet-toolbox 1.1.11 → 1.1.13

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.
Files changed (67) hide show
  1. package/.github/workflows/push.yaml +2 -2
  2. package/README.md +3 -22
  3. package/docs/README.md +8 -8
  4. package/docs/client.md +44 -46
  5. package/docs/monitor.md +2 -2
  6. package/docs/services.md +2 -2
  7. package/docs/setup.md +33 -32
  8. package/docs/storage.md +2 -2
  9. package/docs/wallet.md +44 -46
  10. package/out/src/Setup.d.ts.map +1 -1
  11. package/out/src/Setup.js.map +1 -1
  12. package/out/src/SetupClient.d.ts +2 -2
  13. package/out/src/SetupClient.d.ts.map +1 -1
  14. package/out/src/SetupClient.js +50 -15
  15. package/out/src/SetupClient.js.map +1 -1
  16. package/out/src/services/providers/arcServices.js.map +1 -1
  17. package/out/src/signer/methods/createAction.js +3 -3
  18. package/out/src/signer/methods/createAction.js.map +1 -1
  19. package/out/src/signer/methods/internalizeAction.js.map +1 -1
  20. package/out/src/signer/methods/signAction.js +1 -1
  21. package/out/src/signer/methods/signAction.js.map +1 -1
  22. package/out/src/storage/WalletStorageManager.d.ts +2 -2
  23. package/out/src/storage/WalletStorageManager.js +2 -2
  24. package/out/src/storage/methods/createAction.js.map +1 -1
  25. package/out/src/storage/methods/internalizeAction.js.map +1 -1
  26. package/out/src/utility/ScriptTemplateBRC29.d.ts +25 -0
  27. package/out/src/utility/ScriptTemplateBRC29.d.ts.map +1 -0
  28. package/out/src/utility/{ScriptTemplateSABPPP.js → ScriptTemplateBRC29.js} +7 -8
  29. package/out/src/utility/ScriptTemplateBRC29.js.map +1 -0
  30. package/out/src/utility/index.all.d.ts +1 -1
  31. package/out/src/utility/index.all.d.ts.map +1 -1
  32. package/out/src/utility/index.all.js +1 -1
  33. package/out/src/utility/index.all.js.map +1 -1
  34. package/out/src/utility/index.client.d.ts +1 -1
  35. package/out/src/utility/index.client.d.ts.map +1 -1
  36. package/out/src/utility/index.client.js +1 -1
  37. package/out/src/utility/index.client.js.map +1 -1
  38. package/out/test/Wallet/live/walletLive.man.test.js +2 -2
  39. package/out/test/Wallet/live/walletLive.man.test.js.map +1 -1
  40. package/out/test/utils/TestUtilsWalletStorage.d.ts +1 -2
  41. package/out/test/utils/TestUtilsWalletStorage.d.ts.map +1 -1
  42. package/out/test/utils/TestUtilsWalletStorage.js +3 -5
  43. package/out/test/utils/TestUtilsWalletStorage.js.map +1 -1
  44. package/out/test/wallet/action/createAction.test.js +30 -19
  45. package/out/test/wallet/action/createAction.test.js.map +1 -1
  46. package/out/test/wallet/action/createActionToGenerateBeefs.man.test.js.map +1 -1
  47. package/out/tsconfig.all.tsbuildinfo +1 -1
  48. package/package.json +2 -2
  49. package/src/Setup.ts +1 -0
  50. package/src/SetupClient.ts +20 -16
  51. package/src/services/providers/arcServices.ts +1 -1
  52. package/src/signer/methods/createAction.ts +4 -4
  53. package/src/signer/methods/internalizeAction.ts +1 -1
  54. package/src/signer/methods/signAction.ts +2 -2
  55. package/src/storage/WalletStorageManager.ts +2 -2
  56. package/src/storage/methods/createAction.ts +2 -2
  57. package/src/storage/methods/internalizeAction.ts +1 -1
  58. package/src/utility/{ScriptTemplateSABPPP.ts → ScriptTemplateBRC29.ts} +13 -14
  59. package/src/utility/index.all.ts +1 -1
  60. package/src/utility/index.client.ts +1 -1
  61. package/test/Wallet/live/walletLive.man.test.ts +3 -3
  62. package/test/utils/TestUtilsWalletStorage.ts +6 -7
  63. package/test/wallet/action/createAction.test.ts +35 -28
  64. package/test/wallet/action/createActionToGenerateBeefs.man.test.ts +2 -2
  65. package/out/src/utility/ScriptTemplateSABPPP.d.ts +0 -29
  66. package/out/src/utility/ScriptTemplateSABPPP.d.ts.map +0 -1
  67. package/out/src/utility/ScriptTemplateSABPPP.js.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bsv/wallet-toolbox",
3
- "version": "1.1.11",
3
+ "version": "1.1.13",
4
4
  "description": "BRC100 conforming wallet, wallet storage and wallet signer components",
5
5
  "main": "./out/src/index.js",
6
6
  "types": "./out/src/index.d.ts",
@@ -32,7 +32,7 @@
32
32
  "dependencies": {
33
33
  "@bsv/auth-express-middleware": "^1.0.1",
34
34
  "@bsv/payment-express-middleware": "^1.0.1",
35
- "@bsv/sdk": "^1.3.13",
35
+ "@bsv/sdk": "^1.3.16",
36
36
  "axios": "^0.29.0",
37
37
  "express": "^4.21.2",
38
38
  "knex": "^3.1.0",
package/src/Setup.ts CHANGED
@@ -21,6 +21,7 @@ import { SetupWallet, SetupWalletArgs, StorageKnex } from './index.all'
21
21
  *
22
22
  */
23
23
  export abstract class Setup extends SetupClient {
24
+
24
25
  /**
25
26
  * Adds `Knex` based storage to a `Wallet` configured by `Setup.createWalletOnly`
26
27
  *
@@ -5,6 +5,7 @@ import {
5
5
  CreateActionOutput,
6
6
  CreateActionResult,
7
7
  KeyDeriver,
8
+ LockingScript,
8
9
  P2PKH,
9
10
  PrivateKey,
10
11
  PublicKey,
@@ -20,6 +21,9 @@ import {
20
21
  WalletStorageManager
21
22
  } from './index.client'
22
23
 
24
+ import * as dotenv from 'dotenv'
25
+ dotenv.config()
26
+
23
27
  /**
24
28
  * The `SetupClient` class provides static setup functions to construct BRC-100 compatible
25
29
  * wallets in a variety of configurations.
@@ -52,21 +56,21 @@ export abstract class SetupClient {
52
56
  const mainIdentityKey2 = mainPrivKey2.toPublicKey().toString()
53
57
 
54
58
  const log = `
55
- # Add the following to .env file:
56
- MAIN_TAAL_API_KEY='mainnet_9596de07e92300c6287e4393594ae39c'
57
- TEST_TAAL_API_KEY='testnet_0e6cf72133b43ea2d7861da2a38684e3'
58
- MY_TEST_IDENTITY = '${testIdentityKey1}'
59
- MY_TEST_IDENTITY2 = '${testIdentityKey2}'
60
- MY_MAIN_IDENTITY = '${mainIdentityKey1}'
61
- MY_MAIN_IDENTITY2 = '${mainIdentityKey2}'
62
- DEV_KEYS = '{
63
- "${testIdentityKey1}": "${testPrivKey1.toString()}",
64
- "${testIdentityKey2}": "${testPrivKey2.toString()}"
65
- "${mainIdentityKey1}": "${mainPrivKey1.toString()}",
66
- "${mainIdentityKey2}": "${mainPrivKey2.toString()}"
67
- }'
68
- MYSQL_CONNECTION='{"port":3306,"host":"127.0.0.1","user":"root","password":"<your_password>","database":"<your_database>", "timezone": "Z"}'
69
- `
59
+ # .env file template for working with wallet-toolbox Setup functions.
60
+ MY_TEST_IDENTITY = '${testIdentityKey1}'
61
+ MY_TEST_IDENTITY2 = '${testIdentityKey2}'
62
+ MY_MAIN_IDENTITY = '${mainIdentityKey1}'
63
+ MY_MAIN_IDENTITY2 = '${mainIdentityKey2}'
64
+ MAIN_TAAL_API_KEY='mainnet_9596de07e92300c6287e4393594ae39c'
65
+ TEST_TAAL_API_KEY='testnet_0e6cf72133b43ea2d7861da2a38684e3'
66
+ MYSQL_CONNECTION='{"port":3306,"host":"127.0.0.1","user":"root","password":"<your_password>","database":"<your_database>", "timezone": "Z"}'
67
+ DEV_KEYS = '{
68
+ "${testIdentityKey1}": "${testPrivKey1.toString()}",
69
+ "${testIdentityKey2}": "${testPrivKey2.toString()}"
70
+ "${mainIdentityKey1}": "${mainPrivKey1.toString()}",
71
+ "${mainIdentityKey2}": "${mainPrivKey2.toString()}"
72
+ }'
73
+ `
70
74
  console.log(log)
71
75
 
72
76
  return log
@@ -213,7 +217,7 @@ export abstract class SetupClient {
213
217
  /**
214
218
  * @publicbody
215
219
  */
216
- static getLockP2PKH(address: string) {
220
+ static getLockP2PKH(address: string): LockingScript {
217
221
  const p2pkh = new P2PKH()
218
222
  const lock = p2pkh.lock(address)
219
223
  return lock
@@ -196,7 +196,7 @@ export async function postTxsToTaalArcMiner(
196
196
  for (const txid of txids) {
197
197
  const btx = beef.findTxid(txid)
198
198
  if (btx) {
199
- const tx = btx.tx
199
+ const tx = btx.tx!
200
200
  for (const input of tx.inputs) {
201
201
  if (!input.sourceTXID || input.sourceTXID === '0'.repeat(64)) continue // all zero txid is a coinbase input.
202
202
  let itx = beef.findTxid(input.sourceTXID!)
@@ -10,7 +10,7 @@ import {
10
10
  makeAtomicBeef,
11
11
  PendingSignAction,
12
12
  PendingStorageInput,
13
- ScriptTemplateSABPPP,
13
+ ScriptTemplateBRC29,
14
14
  sdk,
15
15
  verifyTruthy,
16
16
  Wallet
@@ -100,7 +100,7 @@ function makeChangeLock(
100
100
  ): Script {
101
101
  const derivationPrefix = dctr.derivationPrefix
102
102
  const derivationSuffix = verifyTruthy(out.derivationSuffix)
103
- const sabppp = new ScriptTemplateSABPPP({
103
+ const sabppp = new ScriptTemplateBRC29({
104
104
  derivationPrefix,
105
105
  derivationSuffix,
106
106
  keyDeriver: wallet.keyDeriver
@@ -149,7 +149,7 @@ export async function completeSignedTransaction(
149
149
  // Insert SABPPP unlock templates for storage signed inputs
150
150
  /////////////////////
151
151
  for (const pdi of prior.pdi) {
152
- const sabppp = new ScriptTemplateSABPPP({
152
+ const sabppp = new ScriptTemplateBRC29({
153
153
  derivationPrefix: pdi.derivationPrefix,
154
154
  derivationSuffix: pdi.derivationSuffix,
155
155
  keyDeriver: wallet.keyDeriver
@@ -321,7 +321,7 @@ function buildSignableTransaction(
321
321
  }
322
322
  tx.addInput(inputToAdd)
323
323
  } else {
324
- // Type2: SABPPP protocol inputs which are signed using ScriptTemplateSABPPP.
324
+ // Type2: SABPPP protocol inputs which are signed using ScriptTemplateBRC29.
325
325
  if (storageInput.type !== 'P2PKH')
326
326
  throw new sdk.WERR_INVALID_PARAMETER(
327
327
  'type',
@@ -122,7 +122,7 @@ export async function internalizeAction(
122
122
  'tx',
123
123
  `valid AtomicBEEF with newest txid of ${txid}`
124
124
  )
125
- const tx = btx.tx
125
+ const tx = btx.tx!
126
126
 
127
127
  /*
128
128
  for (const i of tx.inputs) {
@@ -9,7 +9,7 @@ import {
9
9
  import {
10
10
  asBsvSdkScript,
11
11
  PendingSignAction,
12
- ScriptTemplateSABPPP,
12
+ ScriptTemplateBRC29,
13
13
  sdk,
14
14
  Wallet
15
15
  } from '../../index.client'
@@ -92,7 +92,7 @@ export async function completeSignedTransaction(
92
92
  // Insert SABPPP unlock templates for wallet signed inputs
93
93
  /////////////////////
94
94
  for (const pdi of prior.pdi) {
95
- const sabppp = new ScriptTemplateSABPPP({
95
+ const sabppp = new ScriptTemplateBRC29({
96
96
  derivationPrefix: pdi.derivationPrefix,
97
97
  derivationSuffix: pdi.derivationSuffix,
98
98
  keyDeriver: wallet.keyDeriver
@@ -32,13 +32,13 @@ import {
32
32
  * If manages multiple `StorageBase` derived storage services: one actice, the rest as backups.
33
33
  *
34
34
  * Of the storage services, one is 'active' at any one time.
35
- * On startup, and whenever triggered by the wallet, `SignerStorage` runs a syncrhonization sequence:
35
+ * On startup, and whenever triggered by the wallet, `WalletStorageManager` runs a syncrhonization sequence:
36
36
  *
37
37
  * 1. While synchronizing, all other access to storage is blocked waiting.
38
38
  * 2. The active service is confirmed, potentially triggering a resolution process if there is disagreement.
39
39
  * 3. Changes are pushed from the active storage service to each inactive, backup service.
40
40
  *
41
- * Some storage services do not support multiple writers. `SignerStorage` manages wait-blocking write requests
41
+ * Some storage services do not support multiple writers. `WalletStorageManager` manages wait-blocking write requests
42
42
  * for these services.
43
43
  */
44
44
  export class WalletStorageManager implements sdk.WalletStorage {
@@ -701,12 +701,12 @@ async function validateRequiredInputs(
701
701
  if (proven) beef.mergeBump(new EntityProvenTx(proven).getMerklePath())
702
702
  }
703
703
  // btx is valid has parsed transaction data.
704
- if (vout >= btx.tx.outputs.length)
704
+ if (vout >= btx.tx!.outputs.length)
705
705
  throw new sdk.WERR_INVALID_PARAMETER(
706
706
  `${txid}.${vout}`,
707
707
  'valid outpoint'
708
708
  )
709
- const so = btx.tx.outputs[vout]
709
+ const so = btx.tx!.outputs[vout]
710
710
  input.satoshis = verifyTruthy(so.satoshis)
711
711
  input.lockingScript = so.lockingScript
712
712
  }
@@ -303,7 +303,7 @@ class InternalizeActionContext {
303
303
  'tx',
304
304
  `valid AtomicBEEF with newest txid of ${txid}`
305
305
  )
306
- const tx = btx.tx
306
+ const tx = btx.tx!
307
307
 
308
308
  /*
309
309
  for (const i of tx.inputs) {
@@ -1,31 +1,33 @@
1
- import { HexString, KeyDeriver, KeyDeriverApi, WalletProtocol } from '@bsv/sdk'
2
1
  import { asBsvSdkPrivateKey, verifyTruthy } from './index.client'
3
2
  import {
3
+ HexString,
4
+ KeyDeriver,
5
+ KeyDeriverApi,
6
+ WalletProtocol,
7
+ ScriptTemplate,
8
+ ScriptTemplateUnlock,
4
9
  LockingScript,
5
10
  P2PKH,
6
11
  PrivateKey,
7
- Script,
8
- ScriptTemplate,
9
- Transaction,
10
- UnlockingScript
12
+ Script
11
13
  } from '@bsv/sdk'
12
14
 
13
- export interface ScriptTemplateParamsSABPPP {
15
+ export const brc29ProtocolID: WalletProtocol = [2, '3241645161d8']
16
+
17
+ export interface ScriptTemplateParamsBRC29 {
14
18
  derivationPrefix?: string
15
19
  derivationSuffix?: string
16
20
  keyDeriver: KeyDeriverApi
17
21
  }
18
22
 
19
- export const brc29ProtocolID: WalletProtocol = [2, '3241645161d8']
20
-
21
23
  /**
22
24
  * Simple Authenticated BSV P2PKH Payment Protocol
23
25
  * https://brc.dev/29
24
26
  */
25
- export class ScriptTemplateSABPPP implements ScriptTemplate {
27
+ export class ScriptTemplateBRC29 implements ScriptTemplate {
26
28
  p2pkh: P2PKH
27
29
 
28
- constructor(public params: ScriptTemplateParamsSABPPP) {
30
+ constructor(public params: ScriptTemplateParamsBRC29) {
29
31
  this.p2pkh = new P2PKH()
30
32
 
31
33
  verifyTruthy(params.derivationPrefix)
@@ -59,10 +61,7 @@ export class ScriptTemplateSABPPP implements ScriptTemplate {
59
61
  lockerPubKey: string,
60
62
  sourceSatoshis?: number,
61
63
  lockingScript?: Script
62
- ): {
63
- sign: (tx: Transaction, inputIndex: number) => Promise<UnlockingScript>
64
- estimateLength: (tx?: Transaction, inputIndex?: number) => Promise<number>
65
- } {
64
+ ): ScriptTemplateUnlock {
66
65
  const derivedPrivateKey = this.getKeyDeriver(unlockerPrivKey)
67
66
  .derivePrivateKey(brc29ProtocolID, this.getKeyID(), lockerPubKey)
68
67
  .toHex()
@@ -1,5 +1,5 @@
1
1
  export * from './stampLog'
2
- export * from './ScriptTemplateSABPPP'
2
+ export * from './ScriptTemplateBRC29'
3
3
  export * from './parseTxScriptOffsets'
4
4
  export * from './tscProofToMerklePath'
5
5
  export * from './utilityHelpers'
@@ -1,5 +1,5 @@
1
1
  export * from './stampLog'
2
- export * from './ScriptTemplateSABPPP'
2
+ export * from './ScriptTemplateBRC29'
3
3
  export * from './parseTxScriptOffsets'
4
4
  export * from './tscProofToMerklePath'
5
5
  export * from './utilityHelpers'
@@ -16,7 +16,7 @@ import {
16
16
  sdk,
17
17
  verifyOne,
18
18
  verifyId,
19
- ScriptTemplateSABPPP,
19
+ ScriptTemplateBRC29,
20
20
  randomBytesBase64,
21
21
  randomBytes,
22
22
  EntityProvenTxReq,
@@ -451,7 +451,7 @@ export function createWalletPaymentOutput(args: {
451
451
  derivationSuffix: string
452
452
  lockingScript: string
453
453
  } {
454
- const t = new ScriptTemplateSABPPP({
454
+ const t = new ScriptTemplateBRC29({
455
455
  derivationPrefix: randomBytesBase64(8),
456
456
  derivationSuffix: randomBytesBase64(8),
457
457
  keyDeriver: new KeyDeriver(PrivateKey.fromString(args.fromRootKeyHex))
@@ -495,7 +495,7 @@ export async function createWalletPaymentAction(args: {
495
495
  }> {
496
496
  const { toIdentityKey, outputSatoshis, keyDeriver, wallet } = args
497
497
 
498
- const t = new ScriptTemplateSABPPP({
498
+ const t = new ScriptTemplateBRC29({
499
499
  derivationPrefix: randomBytesBase64(8),
500
500
  derivationSuffix: randomBytesBase64(8),
501
501
  keyDeriver
@@ -1,4 +1,5 @@
1
1
  import {
2
+ Beef,
2
3
  CreateActionArgs,
3
4
  CreateActionOutput,
4
5
  CreateActionResult,
@@ -52,10 +53,8 @@ import {
52
53
  } from '../../src/index.all'
53
54
 
54
55
  import { Knex, knex as makeKnex } from 'knex'
55
- import { Beef } from '@bsv/sdk'
56
56
 
57
57
  import * as dotenv from 'dotenv'
58
- import { PrivilegedKeyManager, TransactionStatus } from '../../src/sdk'
59
58
  dotenv.config()
60
59
 
61
60
  const localMySqlConnection = process.env.LOCAL_MYSQL_CONNECTION || ''
@@ -172,7 +171,7 @@ export abstract class TestUtilsWalletStorage {
172
171
  expect(st.reference).toBeTruthy()
173
172
  // const tx = Transaction.fromAtomicBEEF(st.tx) // Transaction doesn't support V2 Beef yet.
174
173
  const atomicBeef = Beef.fromBinary(st.tx)
175
- const tx = atomicBeef.txs[atomicBeef.txs.length - 1].tx
174
+ const tx = atomicBeef.txs[atomicBeef.txs.length - 1].tx!
176
175
  for (const input of tx.inputs) {
177
176
  expect(atomicBeef.findTxid(input.sourceTXID!)).toBeTruthy()
178
177
  }
@@ -251,10 +250,10 @@ export abstract class TestUtilsWalletStorage {
251
250
  )
252
251
  const monitor = new Monitor(monopts)
253
252
  monitor.addDefaultTasks()
254
- let privilegedKeyManager: PrivilegedKeyManager | undefined = undefined
253
+ let privilegedKeyManager: sdk.PrivilegedKeyManager | undefined = undefined
255
254
  if (args.privKeyHex) {
256
255
  const privKey = PrivateKey.fromString(args.privKeyHex)
257
- privilegedKeyManager = new PrivilegedKeyManager(async () => privKey)
256
+ privilegedKeyManager = new sdk.PrivilegedKeyManager(async () => privKey)
258
257
  }
259
258
  const wallet = new Wallet({
260
259
  chain,
@@ -1210,7 +1209,7 @@ export abstract class TestUtilsWalletStorage {
1210
1209
  {
1211
1210
  txid: input.sourceOutpoint.split('.')[0],
1212
1211
  satoshis: input.sourceSatoshis,
1213
- status: 'confirmed' as TransactionStatus,
1212
+ status: 'confirmed' as sdk.TransactionStatus,
1214
1213
  description: 'Generated transaction for input',
1215
1214
  lockTime: 0,
1216
1215
  version: 1,
@@ -1260,7 +1259,7 @@ export abstract class TestUtilsWalletStorage {
1260
1259
  {
1261
1260
  txid: `${action.txid}` || `tx_${action.satoshis}_${Date.now()}`,
1262
1261
  satoshis: action.satoshis,
1263
- status: action.status as TransactionStatus,
1262
+ status: action.status as sdk.TransactionStatus,
1264
1263
  description: action.description,
1265
1264
  lockTime: action.lockTime,
1266
1265
  version: action.version,
@@ -35,33 +35,40 @@ describe('createAction test', () => {
35
35
  test('0_invalid_params', async () => {
36
36
  for (const { wallet } of ctxs) {
37
37
  {
38
- const log = `\n${testName()}\n`
39
- const args: CreateActionArgs = {
40
- description: ''
41
- }
42
- // description is too short...
43
- await expectToThrowWERR(sdk.WERR_INVALID_PARAMETER, () =>
44
- wallet.createAction(args)
45
- )
46
- args.description = 'five.'
47
- // no outputs, inputs or sendWith
48
- await expectToThrowWERR(sdk.WERR_INVALID_PARAMETER, () =>
49
- wallet.createAction(args)
50
- )
51
- args.options = { signAndProcess: false }
52
- args.outputs = [
53
- { satoshis: 42, lockingScript: 'fred', outputDescription: 'pay fred' }
38
+ const args: CreateActionArgs[] = [
39
+ // description is too short...
40
+ { description: '' },
41
+ // no outputs, inputs or sendWith
42
+ { description: '12345' },
43
+ // lockingScript must be hexadecimal
44
+ {
45
+ description: '12345',
46
+ outputs: [
47
+ {
48
+ satoshis: 42,
49
+ lockingScript: 'fred',
50
+ outputDescription: 'pay fred'
51
+ }
52
+ ]
53
+ },
54
+ // lockingScript must be even length
55
+ {
56
+ description: '12345',
57
+ outputs: [
58
+ {
59
+ satoshis: 42,
60
+ lockingScript: 'abc',
61
+ outputDescription: 'pay fred'
62
+ }
63
+ ]
64
+ }
54
65
  ]
55
- // lockingScript must be hexadecimal
56
- await expectToThrowWERR(sdk.WERR_INVALID_PARAMETER, () =>
57
- wallet.createAction(args)
58
- )
59
- args.outputs[0].lockingScript = 'fre'
60
- // lockingScript must be even length
61
- await expectToThrowWERR(sdk.WERR_INVALID_PARAMETER, () =>
62
- wallet.createAction(args)
63
- )
64
- if (!noLog) console.log(log)
66
+
67
+ for (const a of args) {
68
+ await expectToThrowWERR(sdk.WERR_INVALID_PARAMETER, () =>
69
+ wallet.createAction(a)
70
+ )
71
+ }
65
72
  }
66
73
  }
67
74
  })
@@ -137,7 +144,7 @@ describe('createAction test', () => {
137
144
  expect(st.reference).toBeTruthy()
138
145
  // const tx = Transaction.fromAtomicBEEF(st.tx) // Transaction doesn't support V2 Beef yet.
139
146
  const atomicBeef = Beef.fromBinary(st.tx)
140
- const tx = atomicBeef.txs[atomicBeef.txs.length - 1].tx
147
+ const tx = atomicBeef.txs[atomicBeef.txs.length - 1].tx!
141
148
  for (const input of tx.inputs) {
142
149
  expect(atomicBeef.findTxid(input.sourceTXID!)).toBeTruthy()
143
150
  }
@@ -194,7 +201,7 @@ describe('createAction test', () => {
194
201
  const st = cr.signableTransaction!
195
202
  expect(st.reference).toBeTruthy()
196
203
  const atomicBeef = Beef.fromBinary(st.tx)
197
- const tx = atomicBeef.txs[atomicBeef.txs.length - 1].tx
204
+ const tx = atomicBeef.txs[atomicBeef.txs.length - 1].tx!
198
205
 
199
206
  tx.inputs[0].unlockingScriptTemplate = unlock
200
207
  await tx.sign()
@@ -217,7 +217,7 @@ async function createAndConsume(
217
217
  expect(st.reference).toBeTruthy()
218
218
  // const tx = Transaction.fromAtomicBEEF(st.tx) // Transaction doesn't support V2 Beef yet.
219
219
  const atomicBeef = bsv.Beef.fromBinary(st.tx)
220
- const tx = atomicBeef.txs[atomicBeef.txs.length - 1].tx
220
+ const tx = atomicBeef.txs[atomicBeef.txs.length - 1].tx!
221
221
  for (const input of tx.inputs) {
222
222
  expect(atomicBeef.findTxid(input.sourceTXID!)).toBeTruthy()
223
223
  }
@@ -273,7 +273,7 @@ async function createAndConsume(
273
273
  const st = cr.signableTransaction!
274
274
  expect(st.reference).toBeTruthy()
275
275
  const atomicBeef: bsv.Beef = bsv.Beef.fromBinary(st.tx)
276
- const tx = atomicBeef.txs[atomicBeef.txs.length - 1].tx
276
+ const tx = atomicBeef.txs[atomicBeef.txs.length - 1].tx!
277
277
 
278
278
  tx.inputs[0].unlockingScriptTemplate = unlock
279
279
  await tx.sign()
@@ -1,29 +0,0 @@
1
- import { HexString, KeyDeriverApi, WalletProtocol } from '@bsv/sdk';
2
- import { LockingScript, P2PKH, PrivateKey, Script, ScriptTemplate, Transaction, UnlockingScript } from '@bsv/sdk';
3
- export interface ScriptTemplateParamsSABPPP {
4
- derivationPrefix?: string;
5
- derivationSuffix?: string;
6
- keyDeriver: KeyDeriverApi;
7
- }
8
- export declare const brc29ProtocolID: WalletProtocol;
9
- /**
10
- * Simple Authenticated BSV P2PKH Payment Protocol
11
- * https://brc.dev/29
12
- */
13
- export declare class ScriptTemplateSABPPP implements ScriptTemplate {
14
- params: ScriptTemplateParamsSABPPP;
15
- p2pkh: P2PKH;
16
- constructor(params: ScriptTemplateParamsSABPPP);
17
- getKeyID(): string;
18
- getKeyDeriver(privKey: PrivateKey | HexString): KeyDeriverApi;
19
- lock(lockerPrivKey: string, unlockerPubKey: string): LockingScript;
20
- unlock(unlockerPrivKey: string, lockerPubKey: string, sourceSatoshis?: number, lockingScript?: Script): {
21
- sign: (tx: Transaction, inputIndex: number) => Promise<UnlockingScript>;
22
- estimateLength: (tx?: Transaction, inputIndex?: number) => Promise<number>;
23
- };
24
- /**
25
- * P2PKH unlock estimateLength is a constant
26
- */
27
- unlockLength: number;
28
- }
29
- //# sourceMappingURL=ScriptTemplateSABPPP.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ScriptTemplateSABPPP.d.ts","sourceRoot":"","sources":["../../../src/utility/ScriptTemplateSABPPP.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAc,aAAa,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAE/E,OAAO,EACL,aAAa,EACb,KAAK,EACL,UAAU,EACV,MAAM,EACN,cAAc,EACd,WAAW,EACX,eAAe,EAChB,MAAM,UAAU,CAAA;AAEjB,MAAM,WAAW,0BAA0B;IACzC,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,gBAAgB,CAAC,EAAE,MAAM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