Fix lint payments p2wpkh
This commit is contained in:
parent
fe62e13023
commit
3ddb88168d
2 changed files with 21 additions and 21 deletions
|
@ -1,9 +1,9 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
const bscript = require("../script");
|
|
||||||
const bcrypto = require("../crypto");
|
const bcrypto = require("../crypto");
|
||||||
const lazy = require("./lazy");
|
|
||||||
const networks_1 = require("../networks");
|
const networks_1 = require("../networks");
|
||||||
|
const bscript = require("../script");
|
||||||
|
const lazy = require("./lazy");
|
||||||
const typef = require('typeforce');
|
const typef = require('typeforce');
|
||||||
const OPS = bscript.OPS;
|
const OPS = bscript.OPS;
|
||||||
const ecc = require('tiny-secp256k1');
|
const ecc = require('tiny-secp256k1');
|
||||||
|
@ -26,7 +26,7 @@ function p2wpkh(a, opts) {
|
||||||
signature: typef.maybe(bscript.isCanonicalScriptSignature),
|
signature: typef.maybe(bscript.isCanonicalScriptSignature),
|
||||||
witness: typef.maybe(typef.arrayOf(typef.Buffer)),
|
witness: typef.maybe(typef.arrayOf(typef.Buffer)),
|
||||||
}, a);
|
}, a);
|
||||||
const _address = lazy.value(function () {
|
const _address = lazy.value(() => {
|
||||||
const result = bech32.decode(a.address);
|
const result = bech32.decode(a.address);
|
||||||
const version = result.words.shift();
|
const version = result.words.shift();
|
||||||
const data = bech32.fromWords(result.words);
|
const data = bech32.fromWords(result.words);
|
||||||
|
@ -38,14 +38,14 @@ function p2wpkh(a, opts) {
|
||||||
});
|
});
|
||||||
const network = a.network || networks_1.bitcoin;
|
const network = a.network || networks_1.bitcoin;
|
||||||
const o = { network };
|
const o = { network };
|
||||||
lazy.prop(o, 'address', function () {
|
lazy.prop(o, 'address', () => {
|
||||||
if (!o.hash)
|
if (!o.hash)
|
||||||
return;
|
return;
|
||||||
const words = bech32.toWords(o.hash);
|
const words = bech32.toWords(o.hash);
|
||||||
words.unshift(0x00);
|
words.unshift(0x00);
|
||||||
return bech32.encode(network.bech32, words);
|
return bech32.encode(network.bech32, words);
|
||||||
});
|
});
|
||||||
lazy.prop(o, 'hash', function () {
|
lazy.prop(o, 'hash', () => {
|
||||||
if (a.output)
|
if (a.output)
|
||||||
return a.output.slice(2, 22);
|
return a.output.slice(2, 22);
|
||||||
if (a.address)
|
if (a.address)
|
||||||
|
@ -53,29 +53,29 @@ function p2wpkh(a, opts) {
|
||||||
if (a.pubkey || o.pubkey)
|
if (a.pubkey || o.pubkey)
|
||||||
return bcrypto.hash160(a.pubkey || o.pubkey);
|
return bcrypto.hash160(a.pubkey || o.pubkey);
|
||||||
});
|
});
|
||||||
lazy.prop(o, 'output', function () {
|
lazy.prop(o, 'output', () => {
|
||||||
if (!o.hash)
|
if (!o.hash)
|
||||||
return;
|
return;
|
||||||
return bscript.compile([OPS.OP_0, o.hash]);
|
return bscript.compile([OPS.OP_0, o.hash]);
|
||||||
});
|
});
|
||||||
lazy.prop(o, 'pubkey', function () {
|
lazy.prop(o, 'pubkey', () => {
|
||||||
if (a.pubkey)
|
if (a.pubkey)
|
||||||
return a.pubkey;
|
return a.pubkey;
|
||||||
if (!a.witness)
|
if (!a.witness)
|
||||||
return;
|
return;
|
||||||
return a.witness[1];
|
return a.witness[1];
|
||||||
});
|
});
|
||||||
lazy.prop(o, 'signature', function () {
|
lazy.prop(o, 'signature', () => {
|
||||||
if (!a.witness)
|
if (!a.witness)
|
||||||
return;
|
return;
|
||||||
return a.witness[0];
|
return a.witness[0];
|
||||||
});
|
});
|
||||||
lazy.prop(o, 'input', function () {
|
lazy.prop(o, 'input', () => {
|
||||||
if (!o.witness)
|
if (!o.witness)
|
||||||
return;
|
return;
|
||||||
return EMPTY_BUFFER;
|
return EMPTY_BUFFER;
|
||||||
});
|
});
|
||||||
lazy.prop(o, 'witness', function () {
|
lazy.prop(o, 'witness', () => {
|
||||||
if (!a.pubkey)
|
if (!a.pubkey)
|
||||||
return;
|
return;
|
||||||
if (!a.signature)
|
if (!a.signature)
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { Payment, PaymentOpts } from './index';
|
|
||||||
import * as bscript from '../script';
|
|
||||||
import * as bcrypto from '../crypto';
|
import * as bcrypto from '../crypto';
|
||||||
import * as lazy from './lazy';
|
|
||||||
import { bitcoin as BITCOIN_NETWORK } from '../networks';
|
import { bitcoin as BITCOIN_NETWORK } from '../networks';
|
||||||
|
import * as bscript from '../script';
|
||||||
|
import { Payment, PaymentOpts } from './index';
|
||||||
|
import * as lazy from './lazy';
|
||||||
const typef = require('typeforce');
|
const typef = require('typeforce');
|
||||||
const OPS = bscript.OPS;
|
const OPS = bscript.OPS;
|
||||||
const ecc = require('tiny-secp256k1');
|
const ecc = require('tiny-secp256k1');
|
||||||
|
@ -33,7 +33,7 @@ export function p2wpkh(a: Payment, opts?: PaymentOpts): Payment {
|
||||||
a,
|
a,
|
||||||
);
|
);
|
||||||
|
|
||||||
const _address = lazy.value(function() {
|
const _address = lazy.value(() => {
|
||||||
const result = bech32.decode(a.address);
|
const result = bech32.decode(a.address);
|
||||||
const version = result.words.shift();
|
const version = result.words.shift();
|
||||||
const data = bech32.fromWords(result.words);
|
const data = bech32.fromWords(result.words);
|
||||||
|
@ -47,36 +47,36 @@ export function p2wpkh(a: Payment, opts?: PaymentOpts): Payment {
|
||||||
const network = a.network || BITCOIN_NETWORK;
|
const network = a.network || BITCOIN_NETWORK;
|
||||||
const o: Payment = { network };
|
const o: Payment = { network };
|
||||||
|
|
||||||
lazy.prop(o, 'address', function() {
|
lazy.prop(o, 'address', () => {
|
||||||
if (!o.hash) return;
|
if (!o.hash) return;
|
||||||
|
|
||||||
const words = bech32.toWords(o.hash);
|
const words = bech32.toWords(o.hash);
|
||||||
words.unshift(0x00);
|
words.unshift(0x00);
|
||||||
return bech32.encode(network.bech32, words);
|
return bech32.encode(network.bech32, words);
|
||||||
});
|
});
|
||||||
lazy.prop(o, 'hash', function() {
|
lazy.prop(o, 'hash', () => {
|
||||||
if (a.output) return a.output.slice(2, 22);
|
if (a.output) return a.output.slice(2, 22);
|
||||||
if (a.address) return _address().data;
|
if (a.address) return _address().data;
|
||||||
if (a.pubkey || o.pubkey) return bcrypto.hash160(a.pubkey! || o.pubkey!);
|
if (a.pubkey || o.pubkey) return bcrypto.hash160(a.pubkey! || o.pubkey!);
|
||||||
});
|
});
|
||||||
lazy.prop(o, 'output', function() {
|
lazy.prop(o, 'output', () => {
|
||||||
if (!o.hash) return;
|
if (!o.hash) return;
|
||||||
return bscript.compile([OPS.OP_0, o.hash]);
|
return bscript.compile([OPS.OP_0, o.hash]);
|
||||||
});
|
});
|
||||||
lazy.prop(o, 'pubkey', function() {
|
lazy.prop(o, 'pubkey', () => {
|
||||||
if (a.pubkey) return a.pubkey;
|
if (a.pubkey) return a.pubkey;
|
||||||
if (!a.witness) return;
|
if (!a.witness) return;
|
||||||
return a.witness[1];
|
return a.witness[1];
|
||||||
});
|
});
|
||||||
lazy.prop(o, 'signature', function() {
|
lazy.prop(o, 'signature', () => {
|
||||||
if (!a.witness) return;
|
if (!a.witness) return;
|
||||||
return a.witness[0];
|
return a.witness[0];
|
||||||
});
|
});
|
||||||
lazy.prop(o, 'input', function() {
|
lazy.prop(o, 'input', () => {
|
||||||
if (!o.witness) return;
|
if (!o.witness) return;
|
||||||
return EMPTY_BUFFER;
|
return EMPTY_BUFFER;
|
||||||
});
|
});
|
||||||
lazy.prop(o, 'witness', function() {
|
lazy.prop(o, 'witness', () => {
|
||||||
if (!a.pubkey) return;
|
if (!a.pubkey) return;
|
||||||
if (!a.signature) return;
|
if (!a.signature) return;
|
||||||
return [a.signature, a.pubkey];
|
return [a.signature, a.pubkey];
|
||||||
|
|
Loading…
Reference in a new issue