@bsv/templates 1.4.0 → 1.4.1
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/dist/cjs/package.json +11 -10
- package/dist/cjs/src/MultiPushDrop.js +4 -9
- package/dist/cjs/src/MultiPushDrop.js.map +1 -1
- package/dist/cjs/src/P2MSKH.js +2 -2
- package/dist/cjs/src/P2MSKH.js.map +1 -1
- package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/esm/src/MultiPushDrop.js +4 -9
- package/dist/esm/src/MultiPushDrop.js.map +1 -1
- package/dist/esm/src/P2MSKH.js +2 -2
- package/dist/esm/src/P2MSKH.js.map +1 -1
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/types/src/MultiPushDrop.d.ts.map +1 -1
- package/dist/types/tsconfig.types.tsbuildinfo +1 -1
- package/package.json +20 -19
- package/src/MultiPushDrop.ts +4 -9
- package/src/P2MSKH.ts +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bsv/templates",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "BSV Blockchain Script Templates",
|
|
6
6
|
"main": "dist/cjs/mod.js",
|
|
@@ -24,18 +24,10 @@
|
|
|
24
24
|
"require": "./dist/cjs/src/*.js"
|
|
25
25
|
}
|
|
26
26
|
},
|
|
27
|
-
"scripts": {
|
|
28
|
-
"test": "npm run build && jest",
|
|
29
|
-
"test:watch": "npm run build && jest --watch",
|
|
30
|
-
"test:coverage": "npm run build && jest --coverage",
|
|
31
|
-
"lint": "ts-standard --fix 'src/**/*.ts'",
|
|
32
|
-
"build": "tsc -b && tsconfig-to-dual-package tsconfig.cjs.json",
|
|
33
|
-
"dev": "tsc -b -w",
|
|
34
|
-
"prepublish": "npm run build"
|
|
35
|
-
},
|
|
36
27
|
"repository": {
|
|
37
28
|
"type": "git",
|
|
38
|
-
"url": "git+https://github.com/bsv-blockchain/ts-
|
|
29
|
+
"url": "git+https://github.com/bsv-blockchain/ts-stack.git",
|
|
30
|
+
"directory": "packages/helpers/ts-templates"
|
|
39
31
|
},
|
|
40
32
|
"keywords": [
|
|
41
33
|
"BSV",
|
|
@@ -48,19 +40,28 @@
|
|
|
48
40
|
"author": "BSV Association",
|
|
49
41
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
50
42
|
"bugs": {
|
|
51
|
-
"url": "https://github.com/bsv-blockchain/ts-
|
|
43
|
+
"url": "https://github.com/bsv-blockchain/ts-stack/issues"
|
|
52
44
|
},
|
|
53
|
-
"homepage": "https://github.com/bsv-blockchain/ts-templates#readme",
|
|
45
|
+
"homepage": "https://github.com/bsv-blockchain/ts-stack/tree/main/packages/helpers/ts-templates#readme",
|
|
54
46
|
"devDependencies": {
|
|
55
|
-
"@bsv/wallet-toolbox": "^1.
|
|
56
|
-
"@types/jest": "^
|
|
57
|
-
"jest": "^
|
|
58
|
-
"ts-jest": "^29.
|
|
47
|
+
"@bsv/wallet-toolbox": "^2.1.27",
|
|
48
|
+
"@types/jest": "^30.0.0",
|
|
49
|
+
"jest": "^30.3.0",
|
|
50
|
+
"ts-jest": "^29.4.9",
|
|
59
51
|
"ts-standard": "^12.0.2",
|
|
60
52
|
"tsconfig-to-dual-package": "^1.2.0",
|
|
61
53
|
"typescript": "^5.2.2"
|
|
62
54
|
},
|
|
63
55
|
"dependencies": {
|
|
64
|
-
"@bsv/sdk": "^1.
|
|
56
|
+
"@bsv/sdk": "^2.1.2"
|
|
57
|
+
},
|
|
58
|
+
"scripts": {
|
|
59
|
+
"test": "npm run build && jest --passWithNoTests",
|
|
60
|
+
"test:watch": "npm run build && jest --watch",
|
|
61
|
+
"test:coverage": "npm run build && jest --coverage",
|
|
62
|
+
"lint": "ts-standard --fix 'src/**/*.ts'",
|
|
63
|
+
"build": "tsc -b && tsconfig-to-dual-package tsconfig.cjs.json",
|
|
64
|
+
"dev": "tsc -b -w",
|
|
65
|
+
"prepublish": "npm run build"
|
|
65
66
|
}
|
|
66
|
-
}
|
|
67
|
+
}
|
package/src/MultiPushDrop.ts
CHANGED
|
@@ -173,20 +173,16 @@ export class MultiPushDrop implements ScriptTemplate {
|
|
|
173
173
|
|
|
174
174
|
// Pick the value on the stack that's right before the locking script.
|
|
175
175
|
// This should be the index of the key to use in the unlock.
|
|
176
|
-
lockPart.push(createMinimallyEncodedScriptChunk([nPublicKeys]))
|
|
177
|
-
lockPart.push({ op: OP.OP_PICK })
|
|
176
|
+
lockPart.push(createMinimallyEncodedScriptChunk([nPublicKeys]), { op: OP.OP_PICK })
|
|
178
177
|
|
|
179
178
|
// Now we use the index to get the actual key.
|
|
180
179
|
lockPart.push({ op: OP.OP_PICK })
|
|
181
180
|
|
|
182
181
|
// We pull the signature from the bottom of the stack, no matter the number of keys.
|
|
183
|
-
lockPart.push({ op: OP.OP_DEPTH })
|
|
184
|
-
lockPart.push({ op: OP.OP_1SUB })
|
|
185
|
-
lockPart.push({ op: OP.OP_PICK })
|
|
182
|
+
lockPart.push({ op: OP.OP_DEPTH }, { op: OP.OP_1SUB }, { op: OP.OP_PICK })
|
|
186
183
|
|
|
187
184
|
// We swap the signature and public key so they're in the correct order, then CHECKSIGVERIFY
|
|
188
|
-
lockPart.push({ op: OP.OP_SWAP })
|
|
189
|
-
lockPart.push({ op: OP.OP_CHECKSIGVERIFY })
|
|
185
|
+
lockPart.push({ op: OP.OP_SWAP }, { op: OP.OP_CHECKSIGVERIFY })
|
|
190
186
|
|
|
191
187
|
// Construct PushDrop Part for fields
|
|
192
188
|
const pushDropPart: Array<{ op: number, data?: number[] }> = []
|
|
@@ -302,8 +298,7 @@ export class MultiPushDrop implements ScriptTemplate {
|
|
|
302
298
|
|
|
303
299
|
// Create Unlocking Script Chunks: <Signature> <Index>
|
|
304
300
|
const unlockingChunks: Array<{ op: number, data?: number[] }> = []
|
|
305
|
-
unlockingChunks.push({ op: sigForScript.length, data: sigForScript })
|
|
306
|
-
unlockingChunks.push(createMinimallyEncodedScriptChunk([unlockerIndex]))
|
|
301
|
+
unlockingChunks.push({ op: sigForScript.length, data: sigForScript }, createMinimallyEncodedScriptChunk([unlockerIndex]))
|
|
307
302
|
return new UnlockingScript(unlockingChunks)
|
|
308
303
|
},
|
|
309
304
|
// Estimate length: Signature (~71-73 bytes) + Index push (1 byte for 0-15, potentially more)
|
package/src/P2MSKH.ts
CHANGED
|
@@ -7,7 +7,7 @@ export interface MultiSigInstructions {
|
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
function concatPubkeys (pubkeys: PublicKey[]): number[] {
|
|
10
|
-
return pubkeys.map((p) => p.toDER() as number[]).
|
|
10
|
+
return pubkeys.map((p) => p.toDER() as number[]).flat()
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
function numberFromScriptChunk (chunk: ScriptChunk): number {
|
|
@@ -192,7 +192,7 @@ export class P2MSKH implements ScriptTemplate {
|
|
|
192
192
|
workingUnlockingScript.writeBin(sigForScript)
|
|
193
193
|
const chunkforSig = workingUnlockingScript.chunks.pop() as ScriptChunk
|
|
194
194
|
// add it to the array before the pubkeys, pushing the other content to the right
|
|
195
|
-
workingUnlockingScript.chunks.splice(
|
|
195
|
+
workingUnlockingScript.chunks.splice(-1, 0, chunkforSig)
|
|
196
196
|
return workingUnlockingScript
|
|
197
197
|
},
|
|
198
198
|
|