33
44var networks = {
55 bitcoin : {
6- magicPrefix : '\x18Bitcoin Signed Message:\n' ,
6+ magic : 0xd9b4bef9 ,
7+ messagePrefix : '\x18Bitcoin Signed Message:\n' ,
78 bip32 : {
89 public : 0x0488b21e ,
910 private : 0x0488ade4
@@ -12,11 +13,11 @@ var networks = {
1213 scriptHash : 0x05 ,
1314 wif : 0x80 ,
1415 dustThreshold : 546 , // https://github.com/bitcoin/bitcoin/blob/v0.9.2/src/core.h#L151-L162
15- feePerKb : 10000 , // https://github.com/bitcoin/bitcoin/blob/v0.9.2/src/main.cpp#L53
16- estimateFee : estimateFee ( 'bitcoin' )
16+ feePerKb : 10000 // https://github.com/bitcoin/bitcoin/blob/v0.9.2/src/main.cpp#L53
1717 } ,
1818 testnet : {
19- magicPrefix : '\x18Bitcoin Signed Message:\n' ,
19+ magic : 0xd9b4bef9 ,
20+ messagePrefix : '\x18Bitcoin Signed Message:\n' ,
2021 bip32 : {
2122 public : 0x043587cf ,
2223 private : 0x04358394
@@ -25,11 +26,11 @@ var networks = {
2526 scriptHash : 0xc4 ,
2627 wif : 0xef ,
2728 dustThreshold : 546 ,
28- feePerKb : 10000 ,
29- estimateFee : estimateFee ( 'testnet' )
29+ feePerKb : 10000
3030 } ,
3131 litecoin : {
32- magicPrefix : '\x19Litecoin Signed Message:\n' ,
32+ magic : 0xd9b4bef9 ,
33+ messagePrefix : '\x19Litecoin Signed Message:\n' ,
3334 bip32 : {
3435 public : 0x019da462 ,
3536 private : 0x019d9cfe
@@ -39,11 +40,10 @@ var networks = {
3940 wif : 0xb0 ,
4041 dustThreshold : 0 , // https://github.com/litecoin-project/litecoin/blob/v0.8.7.2/src/main.cpp#L360-L365
4142 dustSoftThreshold : 100000 , // https://github.com/litecoin-project/litecoin/blob/v0.8.7.2/src/main.h#L53
42- feePerKb : 100000 , // https://github.com/litecoin-project/litecoin/blob/v0.8.7.2/src/main.cpp#L56
43- estimateFee : estimateFee ( 'litecoin' )
43+ feePerKb : 100000 // https://github.com/litecoin-project/litecoin/blob/v0.8.7.2/src/main.cpp#L56
4444 } ,
4545 dogecoin : {
46- magicPrefix : '\x19Dogecoin Signed Message:\n' ,
46+ messagePrefix : '\x19Dogecoin Signed Message:\n' ,
4747 bip32 : {
4848 public : 0x02facafd ,
4949 private : 0x02fac398
@@ -53,11 +53,10 @@ var networks = {
5353 wif : 0x9e ,
5454 dustThreshold : 0 , // https://github.com/dogecoin/dogecoin/blob/v1.7.1/src/core.h#L155-L160
5555 dustSoftThreshold : 100000000 , // https://github.com/dogecoin/dogecoin/blob/v1.7.1/src/main.h#L62
56- feePerKb : 100000000 , // https://github.com/dogecoin/dogecoin/blob/v1.7.1/src/main.cpp#L58
57- estimateFee : estimateFee ( 'dogecoin' )
56+ feePerKb : 100000000 // https://github.com/dogecoin/dogecoin/blob/v1.7.1/src/main.cpp#L58
5857 } ,
5958 viacoin : {
60- magicPrefix : '\x18Viacoin Signed Message:\n' ,
59+ messagePrefix : '\x18Viacoin Signed Message:\n' ,
6160 bip32 : {
6261 public : 0x0488b21e ,
6362 private : 0x0488ade4
@@ -67,11 +66,10 @@ var networks = {
6766 wif : 0xc7 ,
6867 dustThreshold : 560 ,
6968 dustSoftThreshold : 100000 ,
70- feePerKb : 100000 , //
71- estimateFee : estimateFee ( 'viacoin' )
69+ feePerKb : 100000
7270 } ,
7371 viacointestnet : {
74- magicPrefix : '\x18Viacoin Signed Message:\n' ,
72+ messagePrefix : '\x18Viacoin Signed Message:\n' ,
7573 bip32 : {
7674 public : 0x043587cf ,
7775 private : 0x04358394
@@ -81,11 +79,10 @@ var networks = {
8179 wif : 0xff ,
8280 dustThreshold : 560 ,
8381 dustSoftThreshold : 100000 ,
84- feePerKb : 100000 ,
85- estimateFee : estimateFee ( 'viacointestnet' )
82+ feePerKb : 100000
8683 } ,
8784 gamerscoin : {
88- magicPrefix : '\x19Gamerscoin Signed Message:\n' ,
85+ messagePrefix : '\x19Gamerscoin Signed Message:\n' ,
8986 bip32 : {
9087 public : 0x019da462 ,
9188 private : 0x019d9cfe
@@ -95,11 +92,10 @@ var networks = {
9592 wif : 0xA6 ,
9693 dustThreshold : 0 , // https://github.com/gamers-coin/gamers-coinv3/blob/master/src/main.cpp#L358-L363
9794 dustSoftThreshold : 100000 , // https://github.com/gamers-coin/gamers-coinv3/blob/master/src/main.cpp#L51
98- feePerKb : 100000 , // https://github.com/gamers-coin/gamers-coinv3/blob/master/src/main.cpp#L54
99- estimateFee : estimateFee ( 'gamerscoin' )
95+ feePerKb : 100000 // https://github.com/gamers-coin/gamers-coinv3/blob/master/src/main.cpp#L54
10096 } ,
10197 jumbucks : {
102- magicPrefix : '\x19Jumbucks Signed Message:\n' ,
98+ messagePrefix : '\x19Jumbucks Signed Message:\n' ,
10399 bip32 : {
104100 public : 0x037a689a ,
105101 private : 0x037a6460
@@ -109,11 +105,10 @@ var networks = {
109105 wif : 0xab ,
110106 dustThreshold : 0 ,
111107 dustSoftThreshold : 10000 ,
112- feePerKb : 10000 ,
113- estimateFee : estimateFee ( 'jumbucks' )
108+ feePerKb : 10000
114109 } ,
115110 zetacoin : {
116- magicPrefix : '\x18Zetacoin Signed Message:\n' ,
111+ messagePrefix : '\x18Zetacoin Signed Message:\n' ,
117112 bip32 : {
118113 public : 0x0488b21e ,
119114 private : 0x0488ade4
@@ -122,28 +117,35 @@ var networks = {
122117 scriptHash : 0x09 ,
123118 wif : 0xe0 ,
124119 dustThreshold : 546 , // https://github.com/zetacoin/zetacoin/blob/master/src/core.h#L159
125- feePerKb : 10000 , // https://github.com/zetacoin/zetacoin/blob/master/src/main.cpp#L54
126- estimateFee : estimateFee ( 'zetacoin' )
120+ feePerKb : 10000 // https://github.com/zetacoin/zetacoin/blob/master/src/main.cpp#L54
127121 }
128122}
129123
130- function estimateFee ( type ) {
131- return function ( tx ) {
132- var network = networks [ type ]
133- var baseFee = network . feePerKb
134- var byteSize = tx . toBuffer ( ) . length
124+ function estimateFee ( tx , network ) {
125+ var baseFee = network . feePerKb
126+ var byteSize = tx . byteLength ( )
135127
136- var fee = baseFee * Math . ceil ( byteSize / 1000 )
137- if ( network . dustSoftThreshold === undefined ) return fee
128+ var fee = baseFee * Math . ceil ( byteSize / 1000 )
129+ if ( network . dustSoftThreshold === undefined ) return fee
138130
139- tx . outs . forEach ( function ( e ) {
140- if ( e . value < network . dustSoftThreshold ) {
141- fee += baseFee
142- }
143- } )
131+ tx . outs . forEach ( function ( output ) {
132+ if ( output . value < network . dustSoftThreshold ) {
133+ fee += baseFee
134+ }
135+ } )
144136
145- return fee
146- }
137+ return fee
138+ }
139+
140+ // FIXME: 1.5.3 compatibility patch(s)
141+ function patchEstimateFee ( network , tx ) {
142+ return estimateFee ( tx , network )
143+ }
144+
145+ for ( var networkName in networks ) {
146+ var network = networks [ networkName ]
147+
148+ network . estimateFee = patchEstimateFee . bind ( null , network )
147149}
148150
149151module . exports = networks
0 commit comments