|
77 | 77 | sigScript := txIn.SignatureScript |
78 | 78 | pkScript := utxo.PkScript() |
79 | 79 | inputAmount := utxo.Amount() |
| 80 | + tokenData := utxo.tokenData |
80 | 81 |
|
81 | 82 | utxoEntryCache := txscript.NewUtxoCache() |
82 | 83 | for i, in := range txVI.tx.MsgTx().TxIn { |
83 | 84 | if i == txVI.txInIndex { |
84 | | - utxoEntryCache.AddEntry(i, *wire.NewTxOut(utxo.amount, utxo.pkScript)) |
| 85 | + utxoEntryCache.AddEntry(i, *wire.NewTxOut(utxo.amount, utxo.pkScript, tokenData)) |
85 | 86 | continue |
86 | 87 | } |
87 | 88 | u := v.utxoView.LookupEntry(in.PreviousOutPoint) |
|
95 | 96 | v.sendResult(err) |
96 | 97 | break out |
97 | 98 | } |
98 | | - utxoEntryCache.AddEntry(i, *wire.NewTxOut(u.amount, u.pkScript)) |
| 99 | + utxoEntryCache.AddEntry(i, *wire.NewTxOut(u.amount, u.pkScript, u.tokenData)) |
99 | 100 | } |
100 | 101 |
|
101 | 102 | vm, err := txscript.NewEngine(pkScript, txVI.tx.MsgTx(), |
@@ -255,6 +256,19 @@ func ValidateTransactionScripts(tx *bchutil.Tx, utxoView *UtxoViewpoint, |
255 | 256 | cachedHashes = txscript.NewTxSigHashes(tx.MsgTx()) |
256 | 257 | } |
257 | 258 |
|
| 259 | + if cachedHashes != nil { |
| 260 | + utxoCache := txscript.NewUtxoCache() |
| 261 | + for i, in := range tx.MsgTx().TxIn { |
| 262 | + u := utxoView.LookupEntry(in.PreviousOutPoint) |
| 263 | + if u == nil { |
| 264 | + break // Raise error? |
| 265 | + } |
| 266 | + utxoCache.AddEntry(i, *wire.NewTxOut(u.amount, u.pkScript, u.tokenData)) |
| 267 | + } |
| 268 | + |
| 269 | + cachedHashes.AddTxSigHashUtxoFromUtxoCache(tx.MsgTx(), utxoCache) |
| 270 | + } |
| 271 | + |
258 | 272 | // Collect all of the transaction inputs and required information for |
259 | 273 | // validation. |
260 | 274 | sigChecks := uint32(0) |
@@ -319,6 +333,19 @@ func checkBlockScripts(block *bchutil.Block, utxoView *UtxoViewpoint, |
319 | 333 | cachedHashes = txscript.NewTxSigHashes(tx.MsgTx()) |
320 | 334 | } |
321 | 335 |
|
| 336 | + if cachedHashes != nil { |
| 337 | + utxoCache := txscript.NewUtxoCache() |
| 338 | + for i, in := range tx.MsgTx().TxIn { |
| 339 | + u := utxoView.LookupEntry(in.PreviousOutPoint) |
| 340 | + if u == nil { |
| 341 | + break // Raise error? |
| 342 | + } |
| 343 | + utxoCache.AddEntry(i, *wire.NewTxOut(u.amount, u.pkScript, u.tokenData)) |
| 344 | + } |
| 345 | + |
| 346 | + cachedHashes.AddTxSigHashUtxoFromUtxoCache(tx.MsgTx(), utxoCache) |
| 347 | + } |
| 348 | + |
322 | 349 | for txInIdx, txIn := range tx.MsgTx().TxIn { |
323 | 350 | // Skip coinbases. |
324 | 351 | if txIn.PreviousOutPoint.Index == math.MaxUint32 { |
|
0 commit comments