Browse Source

payments/p2ms: add const to p2ms

addLowRGrinding
Daniel Cousens 7 years ago
parent
commit
35e0956ed9
  1. 24
      src/payments/p2ms.js

24
src/payments/p2ms.js

@ -1,11 +1,11 @@
let lazy = require('./lazy') const lazy = require('./lazy')
let typef = require('typeforce') const typef = require('typeforce')
let OPS = require('bitcoin-ops') const OPS = require('bitcoin-ops')
let ecc = require('tiny-secp256k1') const ecc = require('tiny-secp256k1')
let bscript = require('../script') const bscript = require('../script')
let BITCOIN_NETWORK = require('../networks').bitcoin const BITCOIN_NETWORK = require('../networks').bitcoin
let OP_INT_BASE = OPS.OP_RESERVED // OP_1 - 1 const OP_INT_BASE = OPS.OP_RESERVED // OP_1 - 1
function stacksEqual (a, b) { function stacksEqual (a, b) {
if (a.length !== b.length) return false if (a.length !== b.length) return false
@ -41,8 +41,8 @@ function p2ms (a, opts) {
input: typef.maybe(typef.Buffer) input: typef.maybe(typef.Buffer)
}, a) }, a)
let network = a.network || BITCOIN_NETWORK const network = a.network || BITCOIN_NETWORK
let o = { network } const o = { network }
let chunks let chunks
let decoded = false let decoded = false
@ -50,10 +50,8 @@ function p2ms (a, opts) {
if (decoded) return if (decoded) return
decoded = true decoded = true
chunks = bscript.decompile(output) chunks = bscript.decompile(output)
let om = chunks[0] - OP_INT_BASE o.m = chunks[0] - OP_INT_BASE
let on = chunks[chunks.length - 2] - OP_INT_BASE o.n = chunks[chunks.length - 2] - OP_INT_BASE
o.m = om
o.n = on
o.pubkeys = chunks.slice(1, -2) o.pubkeys = chunks.slice(1, -2)
} }

Loading…
Cancel
Save