@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.
- package/.github/workflows/push.yaml +2 -2
- package/README.md +3 -22
- package/docs/README.md +8 -8
- package/docs/client.md +44 -46
- package/docs/monitor.md +2 -2
- package/docs/services.md +2 -2
- package/docs/setup.md +33 -32
- package/docs/storage.md +2 -2
- package/docs/wallet.md +44 -46
- package/out/src/Setup.d.ts.map +1 -1
- package/out/src/Setup.js.map +1 -1
- package/out/src/SetupClient.d.ts +2 -2
- package/out/src/SetupClient.d.ts.map +1 -1
- package/out/src/SetupClient.js +50 -15
- package/out/src/SetupClient.js.map +1 -1
- package/out/src/services/providers/arcServices.js.map +1 -1
- package/out/src/signer/methods/createAction.js +3 -3
- package/out/src/signer/methods/createAction.js.map +1 -1
- package/out/src/signer/methods/internalizeAction.js.map +1 -1
- package/out/src/signer/methods/signAction.js +1 -1
- package/out/src/signer/methods/signAction.js.map +1 -1
- package/out/src/storage/WalletStorageManager.d.ts +2 -2
- package/out/src/storage/WalletStorageManager.js +2 -2
- package/out/src/storage/methods/createAction.js.map +1 -1
- package/out/src/storage/methods/internalizeAction.js.map +1 -1
- package/out/src/utility/ScriptTemplateBRC29.d.ts +25 -0
- package/out/src/utility/ScriptTemplateBRC29.d.ts.map +1 -0
- package/out/src/utility/{ScriptTemplateSABPPP.js → ScriptTemplateBRC29.js} +7 -8
- package/out/src/utility/ScriptTemplateBRC29.js.map +1 -0
- package/out/src/utility/index.all.d.ts +1 -1
- package/out/src/utility/index.all.d.ts.map +1 -1
- package/out/src/utility/index.all.js +1 -1
- package/out/src/utility/index.all.js.map +1 -1
- package/out/src/utility/index.client.d.ts +1 -1
- package/out/src/utility/index.client.d.ts.map +1 -1
- package/out/src/utility/index.client.js +1 -1
- package/out/src/utility/index.client.js.map +1 -1
- package/out/test/Wallet/live/walletLive.man.test.js +2 -2
- package/out/test/Wallet/live/walletLive.man.test.js.map +1 -1
- package/out/test/utils/TestUtilsWalletStorage.d.ts +1 -2
- package/out/test/utils/TestUtilsWalletStorage.d.ts.map +1 -1
- package/out/test/utils/TestUtilsWalletStorage.js +3 -5
- package/out/test/utils/TestUtilsWalletStorage.js.map +1 -1
- package/out/test/wallet/action/createAction.test.js +30 -19
- package/out/test/wallet/action/createAction.test.js.map +1 -1
- package/out/test/wallet/action/createActionToGenerateBeefs.man.test.js.map +1 -1
- package/out/tsconfig.all.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/Setup.ts +1 -0
- package/src/SetupClient.ts +20 -16
- package/src/services/providers/arcServices.ts +1 -1
- package/src/signer/methods/createAction.ts +4 -4
- package/src/signer/methods/internalizeAction.ts +1 -1
- package/src/signer/methods/signAction.ts +2 -2
- package/src/storage/WalletStorageManager.ts +2 -2
- package/src/storage/methods/createAction.ts +2 -2
- package/src/storage/methods/internalizeAction.ts +1 -1
- package/src/utility/{ScriptTemplateSABPPP.ts → ScriptTemplateBRC29.ts} +13 -14
- package/src/utility/index.all.ts +1 -1
- package/src/utility/index.client.ts +1 -1
- package/test/Wallet/live/walletLive.man.test.ts +3 -3
- package/test/utils/TestUtilsWalletStorage.ts +6 -7
- package/test/wallet/action/createAction.test.ts +35 -28
- package/test/wallet/action/createActionToGenerateBeefs.man.test.ts +2 -2
- package/out/src/utility/ScriptTemplateSABPPP.d.ts +0 -29
- package/out/src/utility/ScriptTemplateSABPPP.d.ts.map +0 -1
- 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.
|
|
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.
|
|
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
package/src/SetupClient.ts
CHANGED
|
@@ -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
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
|
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',
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
import {
|
|
10
10
|
asBsvSdkScript,
|
|
11
11
|
PendingSignAction,
|
|
12
|
-
|
|
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
|
|
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, `
|
|
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. `
|
|
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
|
|
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
|
|
709
|
+
const so = btx.tx!.outputs[vout]
|
|
710
710
|
input.satoshis = verifyTruthy(so.satoshis)
|
|
711
711
|
input.lockingScript = so.lockingScript
|
|
712
712
|
}
|
|
@@ -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
|
|
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
|
|
27
|
+
export class ScriptTemplateBRC29 implements ScriptTemplate {
|
|
26
28
|
p2pkh: P2PKH
|
|
27
29
|
|
|
28
|
-
constructor(public params:
|
|
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()
|
package/src/utility/index.all.ts
CHANGED
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
sdk,
|
|
17
17
|
verifyOne,
|
|
18
18
|
verifyId,
|
|
19
|
-
|
|
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
|
|
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
|
|
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
|
|
39
|
-
|
|
40
|
-
description: ''
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
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
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
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,CAAA;IACzB,UAAU,EAAE,aAAa,CAAA;CAC1B;AAED,eAAO,MAAM,eAAe,EAAE,cAAoC,CAAA;AAElE;;;GAGG;AACH,qBAAa,oBAAqB,YAAW,cAAc;IAGtC,MAAM,EAAE,0BAA0B;IAFrD,KAAK,EAAE,KAAK,CAAA;gBAEO,MAAM,EAAE,0BAA0B;IAOrD,QAAQ;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