Remove safe-buffer and add type to bitcoin-ops
This commit is contained in:
parent
3124e50e52
commit
e58d012615
26 changed files with 33 additions and 33 deletions
|
@ -50,7 +50,6 @@
|
|||
"merkle-lib": "^2.0.10",
|
||||
"pushdata-bitcoin": "^1.0.1",
|
||||
"randombytes": "^2.0.1",
|
||||
"safe-buffer": "^5.1.1",
|
||||
"tiny-secp256k1": "^1.0.0",
|
||||
"typeforce": "^1.11.3",
|
||||
"typescript": "^3.2.2",
|
||||
|
|
|
@ -4,7 +4,7 @@ import * as types from './types'
|
|||
import * as bscript from './script'
|
||||
import * as networks from './networks'
|
||||
import * as payments from './payments'
|
||||
const Buffer = require('safe-buffer').Buffer
|
||||
|
||||
const bech32 = require('bech32')
|
||||
const bs58check = require('bs58check')
|
||||
const typeforce = require('typeforce')
|
||||
|
|
|
@ -2,7 +2,7 @@ import { Transaction } from './transaction'
|
|||
import * as types from './types'
|
||||
import * as bcrypto from './crypto'
|
||||
import { reverseBuffer } from './bufferutils'
|
||||
const Buffer = require('safe-buffer').Buffer
|
||||
|
||||
const fastMerkleRoot = require('merkle-lib/fastRoot')
|
||||
const typeforce = require('typeforce')
|
||||
const varuint = require('varuint-bitcoin')
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
const opcodes = require('bitcoin-ops')
|
||||
const bip32 = require('bip32')
|
||||
|
||||
import { Block } from './block'
|
||||
|
@ -10,6 +9,7 @@ import * as crypto from './crypto'
|
|||
import * as networks from './networks'
|
||||
import * as payments from './payments'
|
||||
import * as script from './script'
|
||||
import { OPS as opcodes } from './script'
|
||||
|
||||
export {
|
||||
Block,
|
||||
|
|
|
@ -3,7 +3,7 @@ import * as bscript from '../script'
|
|||
import * as lazy from './lazy'
|
||||
import { bitcoin as BITCOIN_NETWORK } from '../networks'
|
||||
const typef = require('typeforce')
|
||||
const OPS = require('bitcoin-ops')
|
||||
import { OPS } from '../script'
|
||||
|
||||
function stacksEqual (a: Array<Buffer>, b: Array<Buffer>): boolean {
|
||||
if (a.length !== b.length) return false
|
||||
|
@ -32,7 +32,7 @@ export function p2data (a: Payment, opts?: PaymentOpts): Payment {
|
|||
|
||||
lazy.prop(o, 'output', function () {
|
||||
if (!a.data) return
|
||||
return bscript.compile([OPS.OP_RETURN].concat(a.data))
|
||||
return bscript.compile((<Array<Buffer | number>>[OPS.OP_RETURN]).concat(a.data))
|
||||
})
|
||||
lazy.prop(o, 'data', function () {
|
||||
if (!a.output) return
|
||||
|
|
|
@ -3,7 +3,7 @@ import * as bscript from '../script'
|
|||
import * as lazy from './lazy'
|
||||
import { bitcoin as BITCOIN_NETWORK } from '../networks'
|
||||
const typef = require('typeforce')
|
||||
const OPS = require('bitcoin-ops')
|
||||
import { OPS } from '../script'
|
||||
const ecc = require('tiny-secp256k1')
|
||||
|
||||
const OP_INT_BASE = OPS.OP_RESERVED // OP_1 - 1
|
||||
|
@ -87,7 +87,7 @@ export function p2ms (a: Payment, opts?: PaymentOpts): Payment {
|
|||
})
|
||||
lazy.prop(o, 'input', function () {
|
||||
if (!a.signatures) return
|
||||
return bscript.compile([OPS.OP_0].concat(a.signatures))
|
||||
return bscript.compile((<Array<Buffer | number>>[OPS.OP_0]).concat(a.signatures))
|
||||
})
|
||||
lazy.prop(o, 'witness', function () {
|
||||
if (!o.input) return
|
||||
|
|
|
@ -3,7 +3,7 @@ import * as bscript from '../script'
|
|||
import * as lazy from './lazy'
|
||||
import { bitcoin as BITCOIN_NETWORK } from '../networks'
|
||||
const typef = require('typeforce')
|
||||
const OPS = require('bitcoin-ops')
|
||||
import { OPS } from '../script'
|
||||
const ecc = require('tiny-secp256k1')
|
||||
|
||||
// input: {signature}
|
||||
|
|
|
@ -4,7 +4,7 @@ import * as bcrypto from '../crypto'
|
|||
import * as lazy from './lazy'
|
||||
import { bitcoin as BITCOIN_NETWORK } from '../networks'
|
||||
const typef = require('typeforce')
|
||||
const OPS = require('bitcoin-ops')
|
||||
import { OPS } from '../script'
|
||||
const ecc = require('tiny-secp256k1')
|
||||
|
||||
const bs58check = require('bs58check')
|
||||
|
|
|
@ -5,7 +5,7 @@ import * as bcrypto from '../crypto'
|
|||
import * as lazy from './lazy'
|
||||
import { bitcoin as BITCOIN_NETWORK } from '../networks'
|
||||
const typef = require('typeforce')
|
||||
const OPS = require('bitcoin-ops')
|
||||
import { OPS } from '../script'
|
||||
|
||||
const bs58check = require('bs58check')
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import * as bcrypto from '../crypto'
|
|||
import * as lazy from './lazy'
|
||||
import { bitcoin as BITCOIN_NETWORK } from '../networks'
|
||||
const typef = require('typeforce')
|
||||
const OPS = require('bitcoin-ops')
|
||||
import { OPS } from '../script'
|
||||
const ecc = require('tiny-secp256k1')
|
||||
|
||||
const bech32 = require('bech32')
|
||||
|
|
|
@ -5,7 +5,7 @@ import * as bcrypto from '../crypto'
|
|||
import * as lazy from './lazy'
|
||||
import { bitcoin as BITCOIN_NETWORK } from '../networks'
|
||||
const typef = require('typeforce')
|
||||
const OPS = require('bitcoin-ops')
|
||||
import { OPS } from '../script'
|
||||
|
||||
const bech32 = require('bech32')
|
||||
|
||||
|
|
|
@ -1,14 +1,15 @@
|
|||
import * as types from './types'
|
||||
import * as scriptNumber from './script_number'
|
||||
import * as scriptSignature from './script_signature'
|
||||
const Buffer = require('safe-buffer').Buffer
|
||||
const bip66 = require('bip66')
|
||||
const ecc = require('tiny-secp256k1')
|
||||
const pushdata = require('pushdata-bitcoin')
|
||||
const typeforce = require('typeforce')
|
||||
|
||||
const OPS = require('bitcoin-ops')
|
||||
const REVERSE_OPS = require('bitcoin-ops/map')
|
||||
export type OpCode = number
|
||||
export const OPS = <{[index:string]: OpCode}> require('bitcoin-ops')
|
||||
|
||||
const REVERSE_OPS = <{[index:number]: string}> require('bitcoin-ops/map')
|
||||
const OP_INT_BASE = OPS.OP_RESERVED // OP_1 - 1
|
||||
|
||||
function isOPInt (value:number): boolean {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
const Buffer = require('safe-buffer').Buffer
|
||||
|
||||
|
||||
export function decode (buffer: Buffer, maxLength?: number, minimal?: boolean): number {
|
||||
maxLength = maxLength || 4
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import * as types from './types'
|
||||
const bip66 = require('bip66')
|
||||
const Buffer = require('safe-buffer').Buffer
|
||||
|
||||
const typeforce = require('typeforce')
|
||||
|
||||
const ZERO = Buffer.alloc(1, 0)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// OP_0 [signatures ...]
|
||||
|
||||
import * as bscript from '../../script'
|
||||
const OPS = require('bitcoin-ops')
|
||||
import { OPS } from '../../script'
|
||||
|
||||
function partialSignature (value: number | Buffer): boolean {
|
||||
return value === OPS.OP_0 || bscript.isCanonicalScriptSignature(<Buffer>value)
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
import * as bscript from '../../script'
|
||||
import * as types from '../../types'
|
||||
const OPS = require('bitcoin-ops')
|
||||
import { OPS } from '../../script'
|
||||
const OP_INT_BASE = OPS.OP_RESERVED // OP_1 - 1
|
||||
|
||||
export function check (script: Buffer | Array<number | Buffer>, allowIncomplete?: boolean): boolean {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// OP_RETURN {data}
|
||||
import * as bscript from '../script'
|
||||
const OPS = require('bitcoin-ops')
|
||||
import { OPS } from '../script'
|
||||
|
||||
export function check (script: Buffer | Array<number | Buffer>): boolean {
|
||||
const buffer = bscript.compile(script)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// {pubKey} OP_CHECKSIG
|
||||
|
||||
import * as bscript from '../../script'
|
||||
const OPS = require('bitcoin-ops')
|
||||
import { OPS } from '../../script'
|
||||
|
||||
export function check (script: Buffer | Array<number | Buffer>): boolean {
|
||||
const chunks = <Array<number | Buffer>>bscript.decompile(script)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// OP_DUP OP_HASH160 {pubKeyHash} OP_EQUALVERIFY OP_CHECKSIG
|
||||
|
||||
import * as bscript from '../../script'
|
||||
const OPS = require('bitcoin-ops')
|
||||
import { OPS } from '../../script'
|
||||
|
||||
export function check (script: Buffer | Array<number | Buffer>): boolean {
|
||||
const buffer = bscript.compile(script)
|
||||
|
|
|
@ -7,7 +7,7 @@ import * as p2pkh from '../pubkeyhash'
|
|||
import * as p2wpkho from '../witnesspubkeyhash/output'
|
||||
import * as p2wsho from '../witnessscripthash/output'
|
||||
|
||||
const Buffer = require('safe-buffer').Buffer
|
||||
|
||||
|
||||
export function check (script: Buffer | Array<number | Buffer>, allowIncomplete?: boolean): boolean {
|
||||
const chunks = <Array<number | Buffer>>bscript.decompile(script)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// OP_HASH160 {scriptHash} OP_EQUAL
|
||||
|
||||
import * as bscript from '../../script'
|
||||
const OPS = require('bitcoin-ops')
|
||||
import { OPS } from '../../script'
|
||||
|
||||
export function check (script: Buffer | Array<number | Buffer>): boolean {
|
||||
const buffer = bscript.compile(script)
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
|
||||
import * as bscript from '../../script'
|
||||
import * as types from '../../types'
|
||||
const Buffer = require('safe-buffer').Buffer
|
||||
|
||||
const typeforce = require('typeforce')
|
||||
const OPS = require('bitcoin-ops')
|
||||
import { OPS } from '../../script'
|
||||
|
||||
const HEADER: Buffer = Buffer.from('aa21a9ed', 'hex')
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// OP_0 {pubKeyHash}
|
||||
|
||||
import * as bscript from '../../script'
|
||||
const OPS = require('bitcoin-ops')
|
||||
import { OPS } from '../../script'
|
||||
|
||||
export function check (script: Buffer | Array<number | Buffer>): boolean {
|
||||
const buffer = bscript.compile(script)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// OP_0 {scriptHash}
|
||||
|
||||
import * as bscript from '../../script'
|
||||
const OPS = require('bitcoin-ops')
|
||||
import { OPS } from '../../script'
|
||||
|
||||
export function check (script: Buffer | Array<number | Buffer>): boolean {
|
||||
const buffer = bscript.compile(script)
|
||||
|
|
|
@ -3,8 +3,8 @@ import * as bscript from './script'
|
|||
import * as types from './types'
|
||||
import * as bufferutils from './bufferutils'
|
||||
import { reverseBuffer } from './bufferutils'
|
||||
const Buffer = require('safe-buffer').Buffer
|
||||
const opcodes = require('bitcoin-ops')
|
||||
import { OPS as opcodes } from './script'
|
||||
|
||||
const typeforce = require('typeforce')
|
||||
const varuint = require('varuint-bitcoin')
|
||||
|
||||
|
|
|
@ -11,9 +11,9 @@ import * as bscript from './script'
|
|||
import { Payment } from './payments'
|
||||
import * as payments from './payments'
|
||||
import * as classify from './classify'
|
||||
const ops = require('bitcoin-ops')
|
||||
import { OPS as ops } from './script'
|
||||
const typeforce = require('typeforce')
|
||||
const Buffer = require('safe-buffer').Buffer
|
||||
|
||||
const SCRIPT_TYPES = classify.types
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue