Fix lint payments p2wsh

This commit is contained in:
junderw 2019-03-07 13:05:04 +09:00
parent 3ddb88168d
commit f058140ea8
No known key found for this signature in database
GPG key ID: B256185D3A971908
2 changed files with 25 additions and 25 deletions
src/payments

View file

@ -1,8 +1,8 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const bcrypto = require("../crypto");
const networks_1 = require("../networks");
const bscript = require("../script");
const bcrypto = require("../crypto");
const lazy = require("./lazy");
const typef = require('typeforce');
const OPS = bscript.OPS;
@ -11,7 +11,7 @@ const EMPTY_BUFFER = Buffer.alloc(0);
function stacksEqual(a, b) {
if (a.length !== b.length)
return false;
return a.every(function (x, i) {
return a.every((x, i) => {
return x.equals(b[i]);
});
}
@ -36,7 +36,7 @@ function p2wsh(a, opts) {
input: typef.maybe(typef.BufferN(0)),
witness: typef.maybe(typef.arrayOf(typef.Buffer)),
}, a);
const _address = lazy.value(function () {
const _address = lazy.value(() => {
const result = bech32.decode(a.address);
const version = result.words.shift();
const data = bech32.fromWords(result.words);
@ -46,7 +46,7 @@ function p2wsh(a, opts) {
data: Buffer.from(data),
};
});
const _rchunks = lazy.value(function () {
const _rchunks = lazy.value(() => {
return bscript.decompile(a.redeem.input);
});
let network = a.network;
@ -54,14 +54,14 @@ function p2wsh(a, opts) {
network = (a.redeem && a.redeem.network) || networks_1.bitcoin;
}
const o = { network };
lazy.prop(o, 'address', function () {
lazy.prop(o, 'address', () => {
if (!o.hash)
return;
const words = bech32.toWords(o.hash);
words.unshift(0x00);
return bech32.encode(network.bech32, words);
});
lazy.prop(o, 'hash', function () {
lazy.prop(o, 'hash', () => {
if (a.output)
return a.output.slice(2);
if (a.address)
@ -69,12 +69,12 @@ function p2wsh(a, opts) {
if (o.redeem && o.redeem.output)
return bcrypto.sha256(o.redeem.output);
});
lazy.prop(o, 'output', function () {
lazy.prop(o, 'output', () => {
if (!o.hash)
return;
return bscript.compile([OPS.OP_0, o.hash]);
});
lazy.prop(o, 'redeem', function () {
lazy.prop(o, 'redeem', () => {
if (!a.witness)
return;
return {
@ -83,12 +83,12 @@ function p2wsh(a, opts) {
witness: a.witness.slice(0, -1),
};
});
lazy.prop(o, 'input', function () {
lazy.prop(o, 'input', () => {
if (!o.witness)
return;
return EMPTY_BUFFER;
});
lazy.prop(o, 'witness', function () {
lazy.prop(o, 'witness', () => {
// transform redeem input to witness stack?
if (a.redeem &&
a.redeem.input &&