Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
node_modules
bitcoinjs-min.js
digibytejs-min.js
coverage
17 changes: 11 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "bitcoinjs-lib",
"name": "digibytejs-lib",
"version": "1.4.4",
"description": "Client-side Bitcoin JavaScript library",
"description": "Client-side Digibyte JavaScript library",
"main": "./src/index.js",
"keywords": [
"bitcoin",
"digibyte",
"browser",
"client",
"library"
Expand All @@ -29,10 +29,15 @@
"name": "Stefan Thomas",
"email": "justmoon@members.fsf.org",
"url": "http://www.justmoon.net"
}
},
{
"name": "Esotericizm",
"email": "esotericizm@cryptoservices.net",
"url": "http://www.cryptoservices.net"
}
],
"scripts": {
"compile": "browserify ./src/index.js -s bitcoin | uglifyjs > bitcoinjs-min.js",
"compile": "browserify ./src/index.js -s digibyte | uglifyjs > digibytejs-min.js",
"coverage": "istanbul cover _mocha -- test/*.js",
"coveralls": "npm run-script coverage && coveralls < coverage/lcov.info",
"integration": "mocha --reporter list test/integration/*.js",
Expand All @@ -42,7 +47,7 @@
},
"repository": {
"type": "git",
"url": "https://github.com/bitcoinjs/bitcoinjs-lib.git"
"url": "https://github.com/DigiByte-Team/digibytejs-lib.git"
},
"dependencies": {
"bigi": "^1.4.0",
Expand Down
2 changes: 1 addition & 1 deletion src/address.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Address.fromBase58Check = function(string) {
}

Address.fromOutputScript = function(script, network) {
network = network || networks.bitcoin
network = network || networks.digibyte

if (scripts.isPubKeyHashOutput(script)) return new Address(script.chunks[2], network.pubKeyHash)
if (scripts.isScriptHashOutput(script)) return new Address(script.chunks[1], network.scriptHash)
Expand Down
2 changes: 1 addition & 1 deletion src/eckey.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ ECKey.makeRandom = function(compressed, rng) {

// Export functions
ECKey.prototype.toWIF = function(network) {
network = network || networks.bitcoin
network = network || networks.digibyte

var bufferLen = this.pub.compressed ? 34 : 33
var buffer = new Buffer(bufferLen)
Expand Down
2 changes: 1 addition & 1 deletion src/ecpubkey.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ ECPubKey.fromHex = function(hex) {

// Operations
ECPubKey.prototype.getAddress = function(network) {
network = network || networks.bitcoin
network = network || networks.digibyte

return new Address(crypto.hash160(this.toBuffer()), network.pubKeyHash)
}
Expand Down
2 changes: 1 addition & 1 deletion src/hdnode.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function findBIP32NetworkByVersion(version) {
}

function HDNode(K, chainCode, network) {
network = network || networks.bitcoin
network = network || networks.digibyte

typeForce('Buffer', chainCode)

Expand Down
4 changes: 2 additions & 2 deletions src/message.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function magicHash(message, network) {
}

function sign(privKey, message, network) {
network = network || networks.bitcoin
network = network || networks.digibyte

var hash = magicHash(message, network)
var signature = privKey.sign(hash)
Expand All @@ -36,7 +36,7 @@ function verify(address, signature, message, network) {
signature = new Buffer(signature, 'base64')
}

network = network || networks.bitcoin
network = network || networks.digibyte

var hash = magicHash(message, network)
var parsed = ECSignature.parseCompact(signature)
Expand Down
124 changes: 7 additions & 117 deletions src/networks.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,129 +2,19 @@
// Dogecoin BIP32 is a proposed standard: https://bitcointalk.org/index.php?topic=409731

var networks = {
bitcoin: {
magicPrefix: '\x18Bitcoin Signed Message:\n',
digibyte: {
magicPrefix: '\x18Digibyte Signed Message:\n',
bip32: {
public: 0x0488b21e,
private: 0x0488ade4
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

both the same as bitcoin

},
pubKeyHash: 0x00,
scriptHash: 0x05,
wif: 0x80,
dustThreshold: 546, // https://github.com/bitcoin/bitcoin/blob/v0.9.2/src/core.h#L151-L162
feePerKb: 10000, // https://github.com/bitcoin/bitcoin/blob/v0.9.2/src/main.cpp#L53
estimateFee: estimateFee('bitcoin')
},
testnet: {
magicPrefix: '\x18Bitcoin Signed Message:\n',
bip32: {
public: 0x043587cf,
private: 0x04358394
},
pubKeyHash: 0x6f,
scriptHash: 0xc4,
wif: 0xef,
dustThreshold: 546,
feePerKb: 10000,
estimateFee: estimateFee('testnet')
},
litecoin: {
magicPrefix: '\x19Litecoin Signed Message:\n',
bip32: {
public: 0x019da462,
private: 0x019d9cfe
},
pubKeyHash: 0x30,
scriptHash: 0x05,
wif: 0xb0,
dustThreshold: 0, // https://github.com/litecoin-project/litecoin/blob/v0.8.7.2/src/main.cpp#L360-L365
dustSoftThreshold: 100000, // https://github.com/litecoin-project/litecoin/blob/v0.8.7.2/src/main.h#L53
feePerKb: 100000, // https://github.com/litecoin-project/litecoin/blob/v0.8.7.2/src/main.cpp#L56
estimateFee: estimateFee('litecoin')
},
dogecoin: {
magicPrefix: '\x19Dogecoin Signed Message:\n',
bip32: {
public: 0x02facafd,
private: 0x02fac398
},
pubKeyHash: 0x1e,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as dogecoin

scriptHash: 0x16,
wif: 0x9e,
dustThreshold: 0, // https://github.com/dogecoin/dogecoin/blob/v1.7.1/src/core.h#L155-L160
dustSoftThreshold: 100000000, // https://github.com/dogecoin/dogecoin/blob/v1.7.1/src/main.h#L62
feePerKb: 100000000, // https://github.com/dogecoin/dogecoin/blob/v1.7.1/src/main.cpp#L58
estimateFee: estimateFee('dogecoin')
},
viacoin: {
magicPrefix: '\x18Viacoin Signed Message:\n',
bip32: {
public: 0x0488b21e,
private: 0x0488ade4
},
pubKeyHash: 0x47,
scriptHash: 0x21,
wif: 0xc7,
dustThreshold: 560,
dustSoftThreshold: 100000,
feePerKb: 100000, //
estimateFee: estimateFee('viacoin')
},
viacointestnet: {
magicPrefix: '\x18Viacoin Signed Message:\n',
bip32: {
public: 0x043587cf,
private: 0x04358394
},
pubKeyHash: 0x7f,
scriptHash: 0xc4,
wif: 0xff,
dustThreshold: 560,
dustSoftThreshold: 100000,
feePerKb: 100000,
estimateFee: estimateFee('viacointestnet')
},
gamerscoin: {
magicPrefix: '\x19Gamerscoin Signed Message:\n',
bip32: {
public: 0x019da462,
private: 0x019d9cfe
},
pubKeyHash: 0x26,
scriptHash: 0x05,
wif: 0xA6,
dustThreshold: 0, // https://github.com/gamers-coin/gamers-coinv3/blob/master/src/main.cpp#L358-L363
dustSoftThreshold: 100000, // https://github.com/gamers-coin/gamers-coinv3/blob/master/src/main.cpp#L51
feePerKb: 100000, // https://github.com/gamers-coin/gamers-coinv3/blob/master/src/main.cpp#L54
estimateFee: estimateFee('gamerscoin')
},
jumbucks: {
magicPrefix: '\x19Jumbucks Signed Message:\n',
bip32: {
public: 0x037a689a,
private: 0x037a6460
},
pubKeyHash: 0x2b,
scriptHash: 0x05,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as bitcoin

wif: 0xab,
dustThreshold: 0,
dustSoftThreshold: 10000,
feePerKb: 10000,
estimateFee: estimateFee('jumbucks')
},
zetacoin: {
magicPrefix: '\x18Zetacoin Signed Message:\n',
bip32: {
public: 0x0488b21e,
private: 0x0488ade4
},
pubKeyHash: 0x50,
scriptHash: 0x09,
wif: 0xe0,
dustThreshold: 546, // https://github.com/zetacoin/zetacoin/blob/master/src/core.h#L159
feePerKb: 10000, // https://github.com/zetacoin/zetacoin/blob/master/src/main.cpp#L54
estimateFee: estimateFee('zetacoin')
}
wif: 0x80,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as bitcoin

dustThreshold: 546, //
feePerKb: 10000, //
estimateFee: estimateFee('digibyte')
}
}

function estimateFee(type) {
Expand Down
2 changes: 1 addition & 1 deletion src/wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function Wallet(seed, network) {
console.warn('Wallet is deprecated and will be removed in 2.0.0, see #296')

seed = seed || crypto.randomBytes(32)
network = network || networks.bitcoin
network = network || networks.digibyte

// Stored in a closure to make accidental serialization less likely
var masterKey = HDNode.fromSeedBuffer(seed, network)
Expand Down
6 changes: 3 additions & 3 deletions test/bitcoin.core.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ describe('Bitcoin-core', function() {
var string = f[0]
var hex = f[1]
var params = f[2]
var network = networks.bitcoin
var network = networks.digibyte

if (params.isPrivkey) return
if (params.isTestnet) network = networks.testnet
Expand All @@ -71,8 +71,8 @@ describe('Bitcoin-core', function() {
// base58_keys_invalid
describe('Address', function() {
var allowedNetworks = [
networks.bitcoin.pubkeyhash,
networks.bitcoin.scripthash,
networks.digibyte.pubkeyhash,
networks.digibyte.scripthash,
networks.testnet.pubkeyhash,
networks.testnet.scripthash
]
Expand Down
2 changes: 1 addition & 1 deletion test/ecdsa.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ describe('ecdsa', function() {
})

describe('with i ∈ {0,1,2,3}', function() {
var hash = message.magicHash('1111', networks.bitcoin)
var hash = message.magicHash('1111', networks.digibyte)
var e = BigInteger.fromBuffer(hash)

var signatureBuffer = new Buffer('INcvXVVEFyIfHLbDX+xoxlKFn3Wzj9g0UbhObXdMq+YMKC252o5RHFr0/cKdQe1WsBLUBi4morhgZ77obDJVuV0=', 'base64')
Expand Down