script: rename isCanonicalSignature to isCanonicalScriptSignature

This commit is contained in:
Daniel Cousens 2018-06-05 17:17:40 +10:00
parent 726e4c53b6
commit 7592a6bcc2
6 changed files with 12 additions and 11 deletions

View file

@ -181,7 +181,7 @@ function isDefinedHashType (hashType) {
return hashTypeMod > 0x00 && hashTypeMod < 0x04 return hashTypeMod > 0x00 && hashTypeMod < 0x04
} }
function isCanonicalSignature (buffer) { function isCanonicalScriptSignature (buffer) {
if (!Buffer.isBuffer(buffer)) return false if (!Buffer.isBuffer(buffer)) return false
if (!isDefinedHashType(buffer[buffer.length - 1])) return false if (!isDefinedHashType(buffer[buffer.length - 1])) return false
@ -199,7 +199,7 @@ module.exports = {
signature: require('./script_signature'), signature: require('./script_signature'),
isCanonicalPubKey: isCanonicalPubKey, isCanonicalPubKey: isCanonicalPubKey,
isCanonicalSignature: isCanonicalSignature, isCanonicalScriptSignature: isCanonicalScriptSignature,
isPushOnly: isPushOnly, isPushOnly: isPushOnly,
isDefinedHashType: isDefinedHashType isDefinedHashType: isDefinedHashType
} }

View file

@ -7,7 +7,7 @@ var typeforce = require('typeforce')
var OPS = require('bitcoin-ops') var OPS = require('bitcoin-ops')
function partialSignature (value) { function partialSignature (value) {
return value === OPS.OP_0 || bscript.isCanonicalSignature(value) return value === OPS.OP_0 || bscript.isCanonicalScriptSignature(value)
} }
function check (script, allowIncomplete) { function check (script, allowIncomplete) {
@ -19,7 +19,7 @@ function check (script, allowIncomplete) {
return chunks.slice(1).every(partialSignature) return chunks.slice(1).every(partialSignature)
} }
return chunks.slice(1).every(bscript.isCanonicalSignature) return chunks.slice(1).every(bscript.isCanonicalScriptSignature)
} }
check.toJSON = function () { return 'multisig input' } check.toJSON = function () { return 'multisig input' }

View file

@ -7,12 +7,12 @@ function check (script) {
var chunks = bscript.decompile(script) var chunks = bscript.decompile(script)
return chunks.length === 1 && return chunks.length === 1 &&
bscript.isCanonicalSignature(chunks[0]) bscript.isCanonicalScriptSignature(chunks[0])
} }
check.toJSON = function () { return 'pubKey input' } check.toJSON = function () { return 'pubKey input' }
function encodeStack (signature) { function encodeStack (signature) {
typeforce(bscript.isCanonicalSignature, signature) typeforce(bscript.isCanonicalScriptSignature, signature)
return [signature] return [signature]
} }

View file

@ -7,14 +7,14 @@ function check (script) {
var chunks = bscript.decompile(script) var chunks = bscript.decompile(script)
return chunks.length === 2 && return chunks.length === 2 &&
bscript.isCanonicalSignature(chunks[0]) && bscript.isCanonicalScriptSignature(chunks[0]) &&
bscript.isCanonicalPubKey(chunks[1]) bscript.isCanonicalPubKey(chunks[1])
} }
check.toJSON = function () { return 'pubKeyHash input' } check.toJSON = function () { return 'pubKeyHash input' }
function encodeStack (signature, pubKey) { function encodeStack (signature, pubKey) {
typeforce({ typeforce({
signature: bscript.isCanonicalSignature, signature: bscript.isCanonicalScriptSignature,
pubKey: bscript.isCanonicalPubKey pubKey: bscript.isCanonicalPubKey
}, { }, {
signature: signature, signature: signature,

View file

@ -11,14 +11,14 @@ function check (script) {
var chunks = bscript.decompile(script) var chunks = bscript.decompile(script)
return chunks.length === 2 && return chunks.length === 2 &&
bscript.isCanonicalSignature(chunks[0]) && bscript.isCanonicalScriptSignature(chunks[0]) &&
isCompressedCanonicalPubKey(chunks[1]) isCompressedCanonicalPubKey(chunks[1])
} }
check.toJSON = function () { return 'witnessPubKeyHash input' } check.toJSON = function () { return 'witnessPubKeyHash input' }
function encodeStack (signature, pubKey) { function encodeStack (signature, pubKey) {
typeforce({ typeforce({
signature: bscript.isCanonicalSignature, signature: bscript.isCanonicalScriptSignature,
pubKey: isCompressedCanonicalPubKey pubKey: isCompressedCanonicalPubKey
}, { }, {
signature: signature, signature: signature,

View file

@ -19,7 +19,8 @@ describe('script', function () {
} }
}) })
}) })
describe.skip('isCanonicalSignature', function () {}) describe.skip('isCanonicalScriptSignature', function () {
})
describe('fromASM/toASM', function () { describe('fromASM/toASM', function () {
fixtures.valid.forEach(function (f) { fixtures.valid.forEach(function (f) {