merge Script/scripts
This commit is contained in:
parent
151386c46d
commit
e2abe2b3af
14 changed files with 365 additions and 403 deletions
|
@ -7,13 +7,12 @@ var scripts = require('./scripts')
|
|||
var Address = require('./address')
|
||||
var ECPair = require('./ecpair')
|
||||
var ECSignature = require('./ecsignature')
|
||||
var Script = require('./script')
|
||||
var Transaction = require('./transaction')
|
||||
|
||||
function extractInput (txIn) {
|
||||
var redeemScript
|
||||
var scriptSig = txIn.script
|
||||
var scriptSigChunks = Script.decompile(scriptSig)
|
||||
var scriptSigChunks = scripts.decompile(scriptSig)
|
||||
|
||||
var prevOutScript
|
||||
var prevOutType = scripts.classifyInput(scriptSig, true)
|
||||
|
@ -24,7 +23,7 @@ function extractInput (txIn) {
|
|||
redeemScript = scriptSigChunks.slice(-1)[0]
|
||||
prevOutScript = scripts.scriptHashOutput(bcrypto.hash160(redeemScript))
|
||||
|
||||
scriptSig = Script.compile(scriptSigChunks.slice(0, -1))
|
||||
scriptSig = scripts.compile(scriptSigChunks.slice(0, -1))
|
||||
scriptSigChunks = scriptSigChunks.slice(0, -1)
|
||||
|
||||
scriptType = scripts.classifyInput(scriptSig, true)
|
||||
|
@ -35,7 +34,7 @@ function extractInput (txIn) {
|
|||
// pre-empt redeemScript decompilation
|
||||
var redeemScriptChunks
|
||||
if (redeemScript) {
|
||||
redeemScriptChunks = Script.decompile(redeemScript)
|
||||
redeemScriptChunks = scripts.decompile(redeemScript)
|
||||
}
|
||||
|
||||
// Extract hashType, pubKeys and signatures
|
||||
|
@ -148,7 +147,7 @@ TransactionBuilder.prototype.addInput = function (txHash, vout, sequence, prevOu
|
|||
|
||||
var input = {}
|
||||
if (prevOutScript) {
|
||||
var prevOutScriptChunks = Script.decompile(prevOutScript)
|
||||
var prevOutScriptChunks = scripts.decompile(prevOutScript)
|
||||
var prevOutType = scripts.classifyOutput(prevOutScriptChunks)
|
||||
|
||||
// if we can, extract pubKey information
|
||||
|
@ -319,14 +318,14 @@ TransactionBuilder.prototype.sign = function (index, keyPair, redeemScript, hash
|
|||
if (input.prevOutScript) {
|
||||
if (input.prevOutType !== 'scripthash') throw new Error('PrevOutScript must be P2SH')
|
||||
|
||||
var scriptHash = Script.decompile(input.prevOutScript)[1]
|
||||
var scriptHash = scripts.decompile(input.prevOutScript)[1]
|
||||
if (!bufferutils.equal(scriptHash, bcrypto.hash160(redeemScript))) throw new Error('RedeemScript does not match ' + scriptHash.toString('hex'))
|
||||
}
|
||||
|
||||
var scriptType = scripts.classifyOutput(redeemScript)
|
||||
if (!canSignTypes[scriptType]) throw new Error('RedeemScript not supported (' + scriptType + ')')
|
||||
|
||||
var redeemScriptChunks = Script.decompile(redeemScript)
|
||||
var redeemScriptChunks = scripts.decompile(redeemScript)
|
||||
var pubKeys = []
|
||||
switch (scriptType) {
|
||||
case 'multisig':
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue