rename Address to address
This commit is contained in:
parent
8f9d59fb18
commit
18e9cdcc02
6 changed files with 24 additions and 26 deletions
|
@ -1,5 +1,4 @@
|
|||
module.exports = {
|
||||
Address: require('./address'),
|
||||
Block: require('./block'),
|
||||
ECPair: require('./ecpair'),
|
||||
ECSignature: require('./ecsignature'),
|
||||
|
@ -7,6 +6,7 @@ module.exports = {
|
|||
Transaction: require('./transaction'),
|
||||
TransactionBuilder: require('./transaction_builder'),
|
||||
|
||||
address: require('./address'),
|
||||
bufferutils: require('./bufferutils'),
|
||||
crypto: require('./crypto'),
|
||||
message: require('./message'),
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
var address = require('./address')
|
||||
var bcrypto = require('./crypto')
|
||||
var bufferutils = require('./bufferutils')
|
||||
var networks = require('./networks')
|
||||
var ops = require('./opcodes')
|
||||
var scripts = require('./scripts')
|
||||
|
||||
var Address = require('./address')
|
||||
var ECPair = require('./ecpair')
|
||||
var ECSignature = require('./ecsignature')
|
||||
var Transaction = require('./transaction')
|
||||
|
@ -198,7 +198,7 @@ TransactionBuilder.prototype.addOutput = function (scriptPubKey, value) {
|
|||
|
||||
// Attempt to get a script if it's a base58 address string
|
||||
if (typeof scriptPubKey === 'string') {
|
||||
scriptPubKey = Address.toOutputScript(scriptPubKey, this.network)
|
||||
scriptPubKey = address.toOutputScript(scriptPubKey, this.network)
|
||||
}
|
||||
|
||||
return this.tx.addOutput(scriptPubKey, value)
|
||||
|
|
|
@ -1,18 +1,16 @@
|
|||
/* global describe, it */
|
||||
|
||||
var assert = require('assert')
|
||||
var baddress = require('../src/address')
|
||||
var networks = require('../src/networks')
|
||||
var scripts = require('../src/scripts')
|
||||
|
||||
var Address = require('../src/address')
|
||||
|
||||
var fixtures = require('./fixtures/address.json')
|
||||
|
||||
describe('Address', function () {
|
||||
describe('address', function () {
|
||||
describe('fromBase58Check', function () {
|
||||
fixtures.valid.forEach(function (f) {
|
||||
it('decodes ' + f.base58check, function () {
|
||||
var decode = Address.fromBase58Check(f.base58check)
|
||||
var decode = baddress.fromBase58Check(f.base58check)
|
||||
|
||||
assert.strictEqual(decode.version, f.version)
|
||||
assert.strictEqual(decode.hash.toString('hex'), f.hash)
|
||||
|
@ -22,7 +20,7 @@ describe('Address', function () {
|
|||
fixtures.invalid.fromBase58Check.forEach(function (f) {
|
||||
it('throws on ' + f.exception, function () {
|
||||
assert.throws(function () {
|
||||
Address.fromBase58Check(f.address)
|
||||
baddress.fromBase58Check(f.address)
|
||||
}, new RegExp(f.address + ' ' + f.exception))
|
||||
})
|
||||
})
|
||||
|
@ -32,7 +30,7 @@ describe('Address', function () {
|
|||
fixtures.valid.forEach(function (f) {
|
||||
it('parses ' + f.script.slice(0, 30) + '... (' + f.network + ')', function () {
|
||||
var script = scripts.fromASM(f.script)
|
||||
var address = Address.fromOutputScript(script, networks[f.network])
|
||||
var address = baddress.fromOutputScript(script, networks[f.network])
|
||||
|
||||
assert.strictEqual(address, f.base58check)
|
||||
})
|
||||
|
@ -43,7 +41,7 @@ describe('Address', function () {
|
|||
var script = scripts.fromASM(f.script)
|
||||
|
||||
assert.throws(function () {
|
||||
Address.fromOutputScript(script)
|
||||
baddress.fromOutputScript(script)
|
||||
}, new RegExp(f.script + ' ' + f.exception))
|
||||
})
|
||||
})
|
||||
|
@ -52,7 +50,7 @@ describe('Address', function () {
|
|||
describe('toBase58Check', function () {
|
||||
fixtures.valid.forEach(function (f) {
|
||||
it('formats ' + f.hash + ' (' + f.network + ')', function () {
|
||||
var address = Address.toBase58Check(new Buffer(f.hash, 'hex'), f.version)
|
||||
var address = baddress.toBase58Check(new Buffer(f.hash, 'hex'), f.version)
|
||||
|
||||
assert.strictEqual(address, f.base58check)
|
||||
})
|
||||
|
@ -64,7 +62,7 @@ describe('Address', function () {
|
|||
var network = networks[f.network]
|
||||
|
||||
it('exports ' + f.script.slice(0, 30) + '... (' + f.network + ')', function () {
|
||||
var script = Address.toOutputScript(f.base58check, network)
|
||||
var script = baddress.toOutputScript(f.base58check, network)
|
||||
|
||||
assert.strictEqual(scripts.toASM(script), f.script)
|
||||
})
|
||||
|
@ -73,7 +71,7 @@ describe('Address', function () {
|
|||
fixtures.invalid.toOutputScript.forEach(function (f) {
|
||||
it('throws when ' + f.exception, function () {
|
||||
assert.throws(function () {
|
||||
Address.toOutputScript(f.address)
|
||||
baddress.toOutputScript(f.address)
|
||||
}, new RegExp(f.address + ' ' + f.exception))
|
||||
})
|
||||
})
|
||||
|
|
|
@ -37,7 +37,7 @@ describe('Bitcoin-core', function () {
|
|||
})
|
||||
|
||||
// base58_keys_valid
|
||||
describe('Address.toBase58Check', function () {
|
||||
describe('address.toBase58Check', function () {
|
||||
var typeMap = {
|
||||
'pubkey': 'pubKeyHash',
|
||||
'script': 'scriptHash'
|
||||
|
@ -60,7 +60,7 @@ describe('Bitcoin-core', function () {
|
|||
})
|
||||
|
||||
// base58_keys_invalid
|
||||
describe('Address.fromBase58Check', function () {
|
||||
describe('address.fromBase58Check', function () {
|
||||
var allowedNetworks = [
|
||||
bitcoin.networks.bitcoin.pubkeyhash,
|
||||
bitcoin.networks.bitcoin.scripthash,
|
||||
|
@ -73,7 +73,7 @@ describe('Bitcoin-core', function () {
|
|||
|
||||
it('throws on ' + string, function () {
|
||||
assert.throws(function () {
|
||||
var address = bitcoin.Address.fromBase58Check(string)
|
||||
var address = bitcoin.address.fromBase58Check(string)
|
||||
|
||||
assert.notEqual(allowedNetworks.indexOf(address.version), -1, 'Invalid network')
|
||||
}, /(Invalid (checksum|network))|(too (short|long))/)
|
||||
|
|
|
@ -14,9 +14,9 @@ describe('bitcoinjs-lib (multisig)', function () {
|
|||
return new Buffer(hex, 'hex')
|
||||
})
|
||||
|
||||
var redeemScript = bitcoin.scripts.multisigOutput(2, pubKeys) // 2 of 3
|
||||
var scriptPubKey = bitcoin.scripts.scriptHashOutput(bitcoin.crypto.hash160(redeemScript))
|
||||
var address = bitcoin.Address.fromOutputScript(scriptPubKey)
|
||||
var redeemScript = bitcoin.script.multisigOutput(2, pubKeys) // 2 of 3
|
||||
var scriptPubKey = bitcoin.script.scriptHashOutput(bitcoin.crypto.hash160(redeemScript))
|
||||
var address = bitcoin.address.fromOutputScript(scriptPubKey)
|
||||
|
||||
assert.strictEqual(address, '36NUkt6FWUi3LAWBqWRdDmdTWbt91Yvfu7')
|
||||
})
|
||||
|
@ -32,9 +32,9 @@ describe('bitcoinjs-lib (multisig)', function () {
|
|||
].map(function (wif) { return bitcoin.ECPair.fromWIF(wif, bitcoin.networks.testnet) })
|
||||
var pubKeys = keyPairs.map(function (x) { return x.getPublicKeyBuffer() })
|
||||
|
||||
var redeemScript = bitcoin.scripts.multisigOutput(2, pubKeys) // 2 of 4
|
||||
var scriptPubKey = bitcoin.scripts.scriptHashOutput(bitcoin.crypto.hash160(redeemScript))
|
||||
var address = bitcoin.Address.fromOutputScript(scriptPubKey, bitcoin.networks.testnet)
|
||||
var redeemScript = bitcoin.script.multisigOutput(2, pubKeys) // 2 of 4
|
||||
var scriptPubKey = bitcoin.script.scriptHashOutput(bitcoin.crypto.hash160(redeemScript))
|
||||
var address = bitcoin.address.fromOutputScript(scriptPubKey, bitcoin.networks.testnet)
|
||||
|
||||
// attempt to send funds to the source address
|
||||
blockchain.t.faucet(address, 2e4, function (err) {
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
/* global describe, it, beforeEach */
|
||||
|
||||
var address = require('../src/address')
|
||||
var assert = require('assert')
|
||||
var ops = require('../src/opcodes')
|
||||
var script = require('../src/scripts')
|
||||
|
||||
var Address = require('../src/address')
|
||||
var BigInteger = require('bigi')
|
||||
var ECPair = require('../src/ecpair')
|
||||
var Transaction = require('../src/transaction')
|
||||
|
@ -58,14 +58,14 @@ function construct (f, sign) {
|
|||
return txb
|
||||
}
|
||||
|
||||
describe.only('TransactionBuilder', function () {
|
||||
describe('TransactionBuilder', function () {
|
||||
// constants
|
||||
var keyPair = new ECPair(BigInteger.ONE)
|
||||
var scripts = [
|
||||
'1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMH',
|
||||
'1cMh228HTCiwS8ZsaakH8A8wze1JR5ZsP'
|
||||
].map(function (x) {
|
||||
return Address.toOutputScript(x)
|
||||
return address.toOutputScript(x)
|
||||
})
|
||||
var txHash = new Buffer('0e7cea811c0be9f73c0aca591034396e7264473fc25c1ca45195d7417b36cbe2', 'hex')
|
||||
var txb
|
||||
|
|
Loading…
Reference in a new issue