script: minor.

This commit is contained in:
Christopher Jeffrey 2016-04-30 21:08:32 -07:00
parent 8d38178b30
commit 0f4a591665
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD
3 changed files with 12 additions and 8 deletions

View File

@ -146,7 +146,7 @@ Mnemonic.prototype.toSeed = function toSeed() {
};
/**
* Generate mnemonic string from english words.
* Generate a mnemonic phrase from chosen language.
* @returns {String}
*/

View File

@ -689,7 +689,7 @@ Parser.parseBlockHeaders = function parseBlockHeaders(p) {
ts: p.readU32(),
bits: p.readU32(),
nonce: p.readU32()
}
};
};
/**

View File

@ -3494,7 +3494,7 @@ Script.formatASM = function formatASM(code, decode) {
if (Buffer.isBuffer(op)) {
if (op.length <= 4) {
op = Script.num(op, constants.flags.VERIFY_NONE);
out.push(op.toNumber());
out.push(op.toString(10));
continue;
}
@ -3741,11 +3741,11 @@ Script.fromString = function fromString(code) {
op = code[i];
symbol = op.toUpperCase();
if (symbol.indexOf('OP_') === -1)
if (symbol.indexOf('OP_') !== 0)
symbol = 'OP_' + symbol;
if (opcodes[symbol] == null) {
if (op[0] === '\'' || op[0] === '"') {
if (op[0] === '\'') {
op = op.slice(1, -1);
p.writeBytes(Script.encode([new Buffer(op, 'ascii')]));
continue;
@ -3756,8 +3756,8 @@ Script.fromString = function fromString(code) {
p.writeBytes(Script.encode([op]));
continue;
}
assert(op.indexOf('0x') === 0)
op = op.slice(2);
assert(op.indexOf('0x') === 0);
op = op.substring(2);
assert(utils.isHex(op), 'Unknown opcode.');
if (op.length % 2 !== 0)
op = op + '0';
@ -4105,10 +4105,14 @@ Script.checksig = function checksig(msg, sig, key, flags) {
Script.sign = function sign(msg, key, type) {
var sig = bcoin.ec.sign(msg, key);
var p = new BufferWriter();
// Add the sighash type as a single byte
// to the signature.
return Buffer.concat([sig, new Buffer([type])]);
p.writeBytes(sig);
p.writeU8(type);
return p.render();
};
/**