bitcoinjs-lib/src/address.js
Daniel Cousens 74e53b49a5 Script/Transaction: remove untested functions
These functions are not under test, and are unnecessary bloat due to a
confusing API.

Script.from*(asmStr) were two functions that attempted to parse ASM
codes and produce a script from this.
While useful, an parser can be introduced later under a single function
and under test... removed.

Although Script.extractPublicKeys implementation is likely to be correct,
it is not absolute in that what it returns is even strictly a set of
public keys.
It is a useful function, but can be done in a better way later,
probably checking against the Script templates instead.

Transaction.signWithKeys has some inherent undocumented behaviour, and it is not
clear when you would use it over just Transaction.addOutput and
Transaction.sign individually.  Nor does it mimic anything in the
bitcoind API... removed.
2014-05-08 10:59:58 +10:00

27 lines
729 B
JavaScript

var assert = require('assert')
var base58check = require('./base58check')
function Address(hash, version) {
assert(Buffer.isBuffer(hash), 'First argument must be a Buffer')
assert.strictEqual(hash.length, 20, 'Invalid hash length')
assert.strictEqual(version & 0xFF, version, 'Invalid version byte')
this.hash = hash
this.version = version
}
// Import functions
Address.fromBase58Check = function(string) {
var decode = base58check.decode(string)
return new Address(decode.payload, decode.version)
}
// Export functions
Address.prototype.toBase58Check = function () {
return base58check.encode(this.hash, this.version)
}
Address.prototype.toString = Address.prototype.toBase58Check
module.exports = Address