@smartledger/bsv 9.10.1 → 9.11.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.
@@ -102,8 +102,9 @@ var sighashPreimageForForkId = function (transaction, sighashType, inputNumber,
102
102
  writer.writeUInt32LE(input.outputIndex)
103
103
 
104
104
  // scriptCode of the input (serialized as scripts inside CTxOuts)
105
- writer.writeVarintNum(subscript.toBuffer().length)
106
- writer.write(subscript.toBuffer())
105
+ var scriptCode = subscript.toBuffer()
106
+ writer.writeVarintNum(scriptCode.length)
107
+ writer.write(scriptCode)
107
108
 
108
109
  // value of the output spent by this input (8-byte little endian)
109
110
  writer.writeUInt64LEBN(satoshisBN)
@@ -148,8 +149,13 @@ var sighashPreimage = function sighashPreimage (transaction, sighashType, inputN
148
149
  // Copy transaction
149
150
  var txcopy = Transaction.shallowCopy(transaction)
150
151
 
151
- // Copy script
152
- subscript = new Script(subscript)
152
+ // The BIP-143 path below only reads the script. The original algorithm
153
+ // modifies it, so it takes its own copy there; copying a large script up
154
+ // front cost more than the whole digest. Anything that is not a Script yet
155
+ // is converted, as the copy did.
156
+ if (!(subscript instanceof Script)) {
157
+ subscript = new Script(subscript)
158
+ }
153
159
 
154
160
  if (flags & Interpreter.SCRIPT_ENABLE_REPLAY_PROTECTION) {
155
161
  // Legacy chain's value for fork id must be of the form 0xffxxxx.
@@ -192,7 +198,8 @@ var sighashPreimage = function sighashPreimage (transaction, sighashType, inputN
192
198
  return sighashPreimageForForkId(txcopy, sighashType, inputNumber, subscript, satoshisBN)
193
199
  }
194
200
 
195
- // For no ForkId sighash, separators need to be removed.
201
+ // For no ForkId sighash, separators need to be removed — from a copy.
202
+ subscript = new Script(subscript)
196
203
  subscript.removeCodeseparators()
197
204
 
198
205
  var i
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smartledger/bsv",
3
- "version": "9.10.1",
3
+ "version": "9.11.1",
4
4
  "description": "Bitcoin SV library with an interpreter-verified script engine: OP_PUSH_TX covenants, BIP-143 preimage tooling, and consensus flags that match what miners actually enforce. Also ships DID:web / W3C VC-JWT credentials and the Legal Token Protocol.",
5
5
  "author": "SmartLedger Technology <hello@smartledger.technology> (https://smartledger.technology)",
6
6
  "homepage": "https://github.com/codenlighten/smartledger-bsv#readme",
package/version.js CHANGED
@@ -1,3 +1,3 @@
1
1
  'use strict'
2
2
  // GENERATED by scripts/sync-version.js on `npm version` — do not edit.
3
- module.exports = '9.10.1'
3
+ module.exports = '9.11.1'