cryptocoinjs/coinkey

implement method createFactory()

Opened this issue · 0 comments

Implement a new method that returns a function that creates a CoinKey instance with specified versions. For example:

CoinKey.createFactory = function(versions) {
  return function(privateKey) {
    return new CoinKey(privateKey, versions)
  }
}

example usage:

var secureRandom = require('secure-random')
var CoinKey = require('coinkey')

var dogecoinCreator = CoinKey.createFactory({public: 0x9E: private: 0x1E})

var privateKey = secureRandom.randomBuffer(32)
var ck = dogecoinCreator(privateKey)

Any thoughts on a less Java-y name than createFactory()?