Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merge from karel-3d #1

Open
wants to merge 29 commits into
base: zcash
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
e35940d
Merge pull request #4 from wo01/zcash
karelbilek Jul 23, 2018
c69395d
Update README.md
karelbilek Aug 21, 2018
91b7826
Add sapling support
karelbilek Oct 27, 2018
e994d2c
Bump version
karelbilek Oct 27, 2018
9770855
Fixing version bug
karelbilek Oct 27, 2018
bae0a5a
version push
karelbilek Oct 27, 2018
6ff88d2
Remove console logs
karelbilek Oct 27, 2018
1f6b7d8
new npm
karelbilek Oct 27, 2018
b37e2c5
update: added timestamp field to transaction hex
Adman Nov 19, 2018
86eefef
Update README.md
karelbilek Jan 10, 2019
13db881
Merge pull request #10 from Adman/timestamp
karelbilek Jan 31, 2019
19c4122
add npmignore
szymonlesisz Feb 14, 2019
1c50fc0
version 3.6.0
szymonlesisz Feb 14, 2019
a14d827
Update .npmignore
szymonlesisz Feb 14, 2019
eef0e31
change "zcash" field to "network"
szymonlesisz Mar 6, 2019
93ac325
freeze typeforce on current version
szymonlesisz Mar 6, 2019
b7aaa79
remove default params from Transaction
szymonlesisz Mar 6, 2019
0a4edb8
Update coins.js
szymonlesisz Mar 6, 2019
59ac064
add "getExtraData" method + "noStrict" flag
szymonlesisz Mar 7, 2019
0dda689
fix for zcash: supportsJoinSplits
szymonlesisz Mar 7, 2019
c76e410
changes inspired by bitgo-utxo-lib
szymonlesisz Mar 7, 2019
f68ad0d
cleanup and fixes
szymonlesisz Mar 7, 2019
36586aa
change assing of "network" parameter
szymonlesisz Mar 7, 2019
d79a985
"fromBuffer" dash version fix
szymonlesisz Mar 11, 2019
650eccf
add "invalidTransaction" flag
szymonlesisz Mar 11, 2019
ed3c19c
add flowtype delarations
szymonlesisz Mar 11, 2019
f392f4f
Merge pull request #12 from karel-3d/fix/dash
szymonlesisz Mar 11, 2019
c4d6f39
Update CHANGELOG.md
szymonlesisz Mar 11, 2019
bc12b74
version 3.6.1
szymonlesisz Mar 11, 2019
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
9 changes: 9 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Dev directories
.gitignore
.travis.yml
.nyc_output
coverage

# Dependency directory
node_modules
yarn.lock
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
# 3.6.1
__added__
- Added `Transaction.getExtraData` method
- Added/replaced `network` parameter to `Transaction.fromBuffer` and `Transaction.fromHex` methods

__fixed__
- Dash special transaction support
- Zcash version 1 extra data

# 3.6.0
__added__
- Added timestamp to `Transaction` object (Capricoin)

# 3.2.0
__added__
- Added `address.fromBech32/toBech32` (#846)
Expand Down
13 changes: 4 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
This is a fork of https://github.com/bitcoinjs/bitcoinjs-lib with very simple support for zcash (parsing transactions + multibyte addresses).
Deprecation
===

You should not use this if you don't have to support zcash, since it's not as well maintained and tested as bitcoin.js.
Do not use this

Read README at original bitcoinjs-lib

## versions

Version 3.3.2 is rebased on upstream 3.3.2

## LICENSE [MIT](LICENSE)
Use https://github.com/BitGo/bitgo-utxo-lib/
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
{
"name": "bitcoinjs-lib-zcash",
"version": "3.4.2",
"description": "Client-side Bitcoin JavaScript library with simple zcash support",
"version": "3.6.1",
"description": "Client-side Bitcoin JavaScript library with simple zcash and capricoin support",
"main": "./src/index.js",
"engines": {
"node": ">=4.0.0"
},
"keywords": [
"bitcoinjs",
"bitcoin",
"zcash",
"capricoin",
"browserify",
"javascript",
"bitcoinjs"
Expand Down Expand Up @@ -44,7 +46,7 @@
"pushdata-bitcoin": "^1.0.1",
"randombytes": "^2.0.1",
"safe-buffer": "^5.0.1",
"typeforce": "^1.11.3",
"typeforce": "1.11.3",
"varuint-bitcoin": "^1.0.4",
"wif": "^2.0.1"
},
Expand Down
62 changes: 62 additions & 0 deletions src/coins.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// Coins supported by bitgo-bitcoinjs-lib
const typeforce = require('typeforce')

const coins = {
BCH: 'bch',
BSV: 'bsv',
BTC: 'btc',
BTG: 'btg',
LTC: 'ltc',
ZEC: 'zec',
DASH: 'dash',
DIGIBYTE: 'dgb',
DOGECOIN: 'doge',
NAMECOIN: 'nmc',
VERTCOIN: 'vtc',
CAPRICOIN: 'cpc'
}

coins.isBitcoin = function (network) {
return typeforce.value(coins.BTC)(network.coin)
}

coins.isBitcoinCash = function (network) {
return typeforce.value(coins.BCH)(network.coin)
}

coins.isBitcoinSV = function (network) {
return typeforce.value(coins.BSV)(network.coin)
}

coins.isBitcoinGold = function (network) {
return typeforce.value(coins.BTG)(network.coin)
}

coins.isLitecoin = function (network) {
return typeforce.value(coins.LTC)(network.coin)
}

coins.isZcash = function (network) {
return typeforce.value(coins.ZEC)(network.coin)
}

coins.isDash = function (network) {
return typeforce.value(coins.DASH)(network.coin)
}

coins.isCapricoin = function (network) {
return typeforce.value(coins.CAPRICOIN)(network.coin)
}

coins.isValidCoin = typeforce.oneOf(
coins.isBitcoin,
coins.isBitcoinCash,
coins.isBitcoinSV,
coins.isBitcoinGold,
coins.isLitecoin,
coins.isZcash,
coins.isDash,
coins.isCapricoin
)

module.exports = coins
82 changes: 79 additions & 3 deletions src/networks.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// https://en.bitcoin.it/wiki/List_of_address_prefixes
// Dogecoin BIP32 is a proposed standard: https://bitcointalk.org/index.php?topic=409731
var coins = require('./coins')

module.exports = {
bitcoin: {
Expand All @@ -11,7 +12,8 @@ module.exports = {
},
pubKeyHash: 0x00,
scriptHash: 0x05,
wif: 0x80
wif: 0x80,
coin: coins.BTC
},
testnet: {
messagePrefix: '\x18Bitcoin Signed Message:\n',
Expand All @@ -22,7 +24,8 @@ module.exports = {
},
pubKeyHash: 0x6f,
scriptHash: 0xc4,
wif: 0xef
wif: 0xef,
coin: coins.BTC
},
litecoin: {
messagePrefix: '\x19Litecoin Signed Message:\n',
Expand All @@ -32,6 +35,79 @@ module.exports = {
},
pubKeyHash: 0x30,
scriptHash: 0x32,
wif: 0xb0
wif: 0xb0,
coin: coins.LTC
},
dash: {
messagePrefix: '\x19DarkCoin Signed Message:\n',
bip32: {
public: 0x0488b21e,
private: 0x0488ade4
},
pubKeyHash: 0x4c, // https://dash-docs.github.io/en/developer-reference#opcodes
scriptHash: 0x10,
wif: 0xcc,
coin: coins.DASH
},
dashTest: {
messagePrefix: '\x19DarkCoin Signed Message:\n',
bip32: {
public: 0x043587cf,
private: 0x04358394
},
pubKeyHash: 0x8c, // https://dash-docs.github.io/en/developer-reference#opcodes
scriptHash: 0x13,
wif: 0xef, // https://github.com/dashpay/godashutil/blob/master/wif.go#L72
coin: coins.DASH
},
zcash: {
messagePrefix: '\x18ZCash Signed Message:\n',
bech32: 'bc',
bip32: {
public: 0x0488b21e,
private: 0x0488ade4
},
pubKeyHash: 0x1cb8,
scriptHash: 0x1cbd,
wif: 0x80,
// This parameter was introduced in version 3 to allow soft forks, for version 1 and 2 transactions we add a
// dummy value.
consensusBranchId: {
1: 0x00,
2: 0x00,
3: 0x5ba81b19,
4: 0x76b809bb
},
coin: coins.ZEC
},
zcashTest: {
messagePrefix: '\x18ZCash Signed Message:\n',
bech32: 'tb',
bip32: {
public: 0x043587cf,
private: 0x04358394
},
pubKeyHash: 0x1d25,
scriptHash: 0x1cba,
wif: 0xef,
consensusBranchId: {
1: 0x00,
2: 0x00,
3: 0x5ba81b19,
4: 0x76b809bb
},
coin: coins.ZEC
},
capricoin: {
messagePrefix: '\x18Capricoin Signed Message:\n',
bech32: null,
bip32: {
public: 76067358,
private: 76066276
},
pubKeyHash: 28,
scriptHash: 35,
wif: 0xef,
coin: coins.CAPRICOIN
}
}
Loading