Browse Source

Remove safe-buffer and add type to bitcoin-ops

fixTypes
junderw 6 years ago
parent
commit
e58d012615
No known key found for this signature in database GPG Key ID: B256185D3A971908
  1. 1
      package.json
  2. 2
      src/address.ts
  3. 2
      src/block.ts
  4. 2
      src/index.ts
  5. 4
      src/payments/embed.ts
  6. 4
      src/payments/p2ms.ts
  7. 2
      src/payments/p2pk.ts
  8. 2
      src/payments/p2pkh.ts
  9. 2
      src/payments/p2sh.ts
  10. 2
      src/payments/p2wpkh.ts
  11. 2
      src/payments/p2wsh.ts
  12. 7
      src/script.ts
  13. 2
      src/script_number.ts
  14. 2
      src/script_signature.ts
  15. 2
      src/templates/multisig/input.ts
  16. 2
      src/templates/multisig/output.ts
  17. 2
      src/templates/nulldata.ts
  18. 2
      src/templates/pubkey/output.ts
  19. 2
      src/templates/pubkeyhash/output.ts
  20. 2
      src/templates/scripthash/input.ts
  21. 2
      src/templates/scripthash/output.ts
  22. 4
      src/templates/witnesscommitment/output.ts
  23. 2
      src/templates/witnesspubkeyhash/output.ts
  24. 2
      src/templates/witnessscripthash/output.ts
  25. 4
      src/transaction.ts
  26. 4
      src/transaction_builder.ts

1
package.json

@ -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",

2
src/address.ts

@ -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
src/block.ts

@ -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')

2
src/index.ts

@ -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,

4
src/payments/embed.ts

@ -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

4
src/payments/p2ms.ts

@ -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

2
src/payments/p2pk.ts

@ -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}

2
src/payments/p2pkh.ts

@ -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')

2
src/payments/p2sh.ts

@ -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')

2
src/payments/p2wpkh.ts

@ -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')

2
src/payments/p2wsh.ts

@ -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')

7
src/script.ts

@ -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 {

2
src/script_number.ts

@ -1,4 +1,4 @@
const Buffer = require('safe-buffer').Buffer
export function decode (buffer: Buffer, maxLength?: number, minimal?: boolean): number {
maxLength = maxLength || 4

2
src/script_signature.ts

@ -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)

2
src/templates/multisig/input.ts

@ -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
src/templates/multisig/output.ts

@ -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 {

2
src/templates/nulldata.ts

@ -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)

2
src/templates/pubkey/output.ts

@ -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)

2
src/templates/pubkeyhash/output.ts

@ -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)

2
src/templates/scripthash/input.ts

@ -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)

2
src/templates/scripthash/output.ts

@ -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)

4
src/templates/witnesscommitment/output.ts

@ -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')

2
src/templates/witnesspubkeyhash/output.ts

@ -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)

2
src/templates/witnessscripthash/output.ts

@ -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)

4
src/transaction.ts

@ -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')

4
src/transaction_builder.ts

@ -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…
Cancel
Save