mirror of
https://github.com/mimblewimble/grin.git
synced 2025-02-01 08:51:08 +03:00
Re-launch floonet (#2249)
* Fix secondary scaling bugs; rename is_testnet -> is_floonet (#2215) * add global::is_mainnet() * use it to change pre-genesis pow type * rename is_testnet -> is_floonet * Support multiple chain configurations (#2217) * Support multiple chain configurations Supports generating the proper configuration for each chain type (mainnet, floonet, usernet). Will run them by default under their respective root directory (~/.grin/main, ~/.grin/floo, etc). Assigned default ports for mainnet, overriding them to keep Floonet ports unchanged. For now, starting on mainnet will abort. * Fixed usernet command line help message. Fixes #2217 * Differing magic numbers for each chain type (#2208) * stick to e=H(R|P|m) when use schnorr signature (#2200) * stick to e=H(R|P|m) when use schnorr signature * (1)add verify_slate_messages for wallet receive (2)log the message content * remove debug log on verify_slate_messages * verify the sender's message signature when receive_tx in wallet listen * Revert "remove debug log on verify_slate_messages" This reverts commit65ea32a407
. * Revert "rustfmt" This reverts commitc380ab9185
. * Revert "(1)add verify_slate_messages for wallet receive (2)log the message content" This reverts commit9584ca7a89
. * [re-floonet] Keychain Floonet BIP32 version/network option (#2235) * add 'is_floonet' property to keychain * fix hex encoding and tests * Fix couple floonet loose ends (#2230) * Fix couple floonet loose ends. Fixes #2216 * Doc fix for sig message * Refuse unkown kernel features (#2244) * Minor: magic number change for re-floonet * Set pre genesis is_secondary to true (#2247) * Minor: tx validation error display underlying * New floonet genesis * genesis rustfmt * Use chain-specific config for wallet toml gen * Fix default wallet_listener_url * New more reasonable genesis block, bumped version * genesis rustfmt * Couple minor fixes to genesis generation script
This commit is contained in:
parent
80f7ae678a
commit
9234e3c251
57 changed files with 529 additions and 435 deletions
133
Cargo.lock
generated
133
Cargo.lock
generated
|
@ -658,7 +658,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "grin"
|
name = "grin"
|
||||||
version = "0.4.2"
|
version = "0.5.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"blake2-rfc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
"blake2-rfc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"built 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"built 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -670,16 +670,16 @@ dependencies = [
|
||||||
"failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"failure_derive 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"failure_derive 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"flate2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
"flate2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"grin_api 0.4.2",
|
"grin_api 0.5.0",
|
||||||
"grin_chain 0.4.2",
|
"grin_chain 0.5.0",
|
||||||
"grin_config 0.4.2",
|
"grin_config 0.5.0",
|
||||||
"grin_core 0.4.2",
|
"grin_core 0.5.0",
|
||||||
"grin_keychain 0.4.2",
|
"grin_keychain 0.5.0",
|
||||||
"grin_p2p 0.4.2",
|
"grin_p2p 0.5.0",
|
||||||
"grin_servers 0.4.2",
|
"grin_servers 0.5.0",
|
||||||
"grin_store 0.4.2",
|
"grin_store 0.5.0",
|
||||||
"grin_util 0.4.2",
|
"grin_util 0.5.0",
|
||||||
"grin_wallet 0.4.2",
|
"grin_wallet 0.5.0",
|
||||||
"humansize 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"humansize 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"reqwest 0.9.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"reqwest 0.9.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -692,17 +692,17 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "grin_api"
|
name = "grin_api"
|
||||||
version = "0.4.2"
|
version = "0.5.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"failure_derive 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"failure_derive 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)",
|
"futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"grin_chain 0.4.2",
|
"grin_chain 0.5.0",
|
||||||
"grin_core 0.4.2",
|
"grin_core 0.5.0",
|
||||||
"grin_p2p 0.4.2",
|
"grin_p2p 0.5.0",
|
||||||
"grin_pool 0.4.2",
|
"grin_pool 0.5.0",
|
||||||
"grin_store 0.4.2",
|
"grin_store 0.5.0",
|
||||||
"grin_util 0.4.2",
|
"grin_util 0.5.0",
|
||||||
"http 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
"http 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"hyper 0.12.17 (registry+https://github.com/rust-lang/crates.io-index)",
|
"hyper 0.12.17 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"hyper-rustls 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"hyper-rustls 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -723,7 +723,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "grin_chain"
|
name = "grin_chain"
|
||||||
version = "0.4.2"
|
version = "0.5.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
"bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
"byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -732,10 +732,10 @@ dependencies = [
|
||||||
"env_logger 0.5.13 (registry+https://github.com/rust-lang/crates.io-index)",
|
"env_logger 0.5.13 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"failure_derive 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"failure_derive 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"grin_core 0.4.2",
|
"grin_core 0.5.0",
|
||||||
"grin_keychain 0.4.2",
|
"grin_keychain 0.5.0",
|
||||||
"grin_store 0.4.2",
|
"grin_store 0.5.0",
|
||||||
"grin_util 0.4.2",
|
"grin_util 0.5.0",
|
||||||
"lmdb-zero 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
"lmdb-zero 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"lru-cache 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"lru-cache 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -746,13 +746,14 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "grin_config"
|
name = "grin_config"
|
||||||
version = "0.4.2"
|
version = "0.5.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"dirs 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
"dirs 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"grin_p2p 0.4.2",
|
"grin_core 0.5.0",
|
||||||
"grin_servers 0.4.2",
|
"grin_p2p 0.5.0",
|
||||||
"grin_util 0.4.2",
|
"grin_servers 0.5.0",
|
||||||
"grin_wallet 0.4.2",
|
"grin_util 0.5.0",
|
||||||
|
"grin_wallet 0.5.0",
|
||||||
"pretty_assertions 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"pretty_assertions 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"serde 1.0.81 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde 1.0.81 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -762,7 +763,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "grin_core"
|
name = "grin_core"
|
||||||
version = "0.4.2"
|
version = "0.5.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
"bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"blake2-rfc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
"blake2-rfc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -771,8 +772,8 @@ dependencies = [
|
||||||
"croaring 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
"croaring 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"failure_derive 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"failure_derive 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"grin_keychain 0.4.2",
|
"grin_keychain 0.5.0",
|
||||||
"grin_util 0.4.2",
|
"grin_util 0.5.0",
|
||||||
"lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"lru-cache 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"lru-cache 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -787,12 +788,12 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "grin_keychain"
|
name = "grin_keychain"
|
||||||
version = "0.4.2"
|
version = "0.5.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"blake2-rfc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
"blake2-rfc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
"byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"digest 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
"digest 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"grin_util 0.4.2",
|
"grin_util 0.5.0",
|
||||||
"hmac 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"hmac 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -808,16 +809,16 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "grin_p2p"
|
name = "grin_p2p"
|
||||||
version = "0.4.2"
|
version = "0.5.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
"bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"bytes 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
"bytes 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
"chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"enum_primitive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"enum_primitive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"grin_core 0.4.2",
|
"grin_core 0.5.0",
|
||||||
"grin_pool 0.4.2",
|
"grin_pool 0.5.0",
|
||||||
"grin_store 0.4.2",
|
"grin_store 0.5.0",
|
||||||
"grin_util 0.4.2",
|
"grin_util 0.5.0",
|
||||||
"lmdb-zero 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
"lmdb-zero 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
|
"net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -829,15 +830,15 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "grin_pool"
|
name = "grin_pool"
|
||||||
version = "0.4.2"
|
version = "0.5.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"blake2-rfc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
"blake2-rfc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
"chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"grin_chain 0.4.2",
|
"grin_chain 0.5.0",
|
||||||
"grin_core 0.4.2",
|
"grin_core 0.5.0",
|
||||||
"grin_keychain 0.4.2",
|
"grin_keychain 0.5.0",
|
||||||
"grin_store 0.4.2",
|
"grin_store 0.5.0",
|
||||||
"grin_util 0.4.2",
|
"grin_util 0.5.0",
|
||||||
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"serde 1.0.81 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde 1.0.81 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -860,21 +861,21 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "grin_servers"
|
name = "grin_servers"
|
||||||
version = "0.4.2"
|
version = "0.5.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"blake2-rfc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
"blake2-rfc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"bufstream 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
"bufstream 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
"chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)",
|
"futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"grin_api 0.4.2",
|
"grin_api 0.5.0",
|
||||||
"grin_chain 0.4.2",
|
"grin_chain 0.5.0",
|
||||||
"grin_core 0.4.2",
|
"grin_core 0.5.0",
|
||||||
"grin_keychain 0.4.2",
|
"grin_keychain 0.5.0",
|
||||||
"grin_p2p 0.4.2",
|
"grin_p2p 0.5.0",
|
||||||
"grin_pool 0.4.2",
|
"grin_pool 0.5.0",
|
||||||
"grin_store 0.4.2",
|
"grin_store 0.5.0",
|
||||||
"grin_util 0.4.2",
|
"grin_util 0.5.0",
|
||||||
"grin_wallet 0.4.2",
|
"grin_wallet 0.5.0",
|
||||||
"http 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
"http 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"hyper 0.12.17 (registry+https://github.com/rust-lang/crates.io-index)",
|
"hyper 0.12.17 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"hyper-staticfile 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"hyper-staticfile 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -890,7 +891,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "grin_store"
|
name = "grin_store"
|
||||||
version = "0.4.2"
|
version = "0.5.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
"byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
"chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -899,8 +900,8 @@ dependencies = [
|
||||||
"failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"failure_derive 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"failure_derive 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"filetime 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
"filetime 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"grin_core 0.4.2",
|
"grin_core 0.5.0",
|
||||||
"grin_util 0.4.2",
|
"grin_util 0.5.0",
|
||||||
"libc 0.2.44 (registry+https://github.com/rust-lang/crates.io-index)",
|
"libc 0.2.44 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"lmdb-zero 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
"lmdb-zero 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -912,7 +913,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "grin_util"
|
name = "grin_util"
|
||||||
version = "0.4.2"
|
version = "0.5.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"backtrace 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
"backtrace 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"base64 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"base64 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -932,7 +933,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "grin_wallet"
|
name = "grin_wallet"
|
||||||
version = "0.4.2"
|
version = "0.5.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"blake2-rfc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
"blake2-rfc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
"byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -940,13 +941,13 @@ dependencies = [
|
||||||
"failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"failure_derive 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"failure_derive 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)",
|
"futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"grin_api 0.4.2",
|
"grin_api 0.5.0",
|
||||||
"grin_chain 0.4.2",
|
"grin_chain 0.5.0",
|
||||||
"grin_config 0.4.2",
|
"grin_config 0.5.0",
|
||||||
"grin_core 0.4.2",
|
"grin_core 0.5.0",
|
||||||
"grin_keychain 0.4.2",
|
"grin_keychain 0.5.0",
|
||||||
"grin_store 0.4.2",
|
"grin_store 0.5.0",
|
||||||
"grin_util 0.4.2",
|
"grin_util 0.5.0",
|
||||||
"hyper 0.12.17 (registry+https://github.com/rust-lang/crates.io-index)",
|
"hyper 0.12.17 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"prettytable-rs 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"prettytable-rs 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
|
22
Cargo.toml
22
Cargo.toml
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "grin"
|
name = "grin"
|
||||||
version = "0.4.2"
|
version = "0.5.0"
|
||||||
authors = ["Grin Developers <mimblewimble@lists.launchpad.net>"]
|
authors = ["Grin Developers <mimblewimble@lists.launchpad.net>"]
|
||||||
description = "Simple, private and scalable cryptocurrency implementation based on the MimbleWimble chain format."
|
description = "Simple, private and scalable cryptocurrency implementation based on the MimbleWimble chain format."
|
||||||
license = "Apache-2.0"
|
license = "Apache-2.0"
|
||||||
|
@ -35,14 +35,14 @@ term = "0.5"
|
||||||
failure = "0.1"
|
failure = "0.1"
|
||||||
failure_derive = "0.1"
|
failure_derive = "0.1"
|
||||||
|
|
||||||
grin_api = { path = "./api", version = "0.4.2" }
|
grin_api = { path = "./api", version = "0.5.0" }
|
||||||
grin_config = { path = "./config", version = "0.4.2" }
|
grin_config = { path = "./config", version = "0.5.0" }
|
||||||
grin_core = { path = "./core", version = "0.4.2" }
|
grin_core = { path = "./core", version = "0.5.0" }
|
||||||
grin_keychain = { path = "./keychain", version = "0.4.2" }
|
grin_keychain = { path = "./keychain", version = "0.5.0" }
|
||||||
grin_p2p = { path = "./p2p", version = "0.4.2" }
|
grin_p2p = { path = "./p2p", version = "0.5.0" }
|
||||||
grin_servers = { path = "./servers", version = "0.4.2" }
|
grin_servers = { path = "./servers", version = "0.5.0" }
|
||||||
grin_util = { path = "./util", version = "0.4.2" }
|
grin_util = { path = "./util", version = "0.5.0" }
|
||||||
grin_wallet = { path = "./wallet", version = "0.4.2" }
|
grin_wallet = { path = "./wallet", version = "0.5.0" }
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
built = "0.3"
|
built = "0.3"
|
||||||
|
@ -51,5 +51,5 @@ flate2 = "1.0"
|
||||||
tar = "0.4"
|
tar = "0.4"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
grin_chain = { path = "./chain", version = "0.4.2" }
|
grin_chain = { path = "./chain", version = "0.5.0" }
|
||||||
grin_store = { path = "./store", version = "0.4.2" }
|
grin_store = { path = "./store", version = "0.5.0" }
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "grin_api"
|
name = "grin_api"
|
||||||
version = "0.4.2"
|
version = "0.5.0"
|
||||||
authors = ["Grin Developers <mimblewimble@lists.launchpad.net>"]
|
authors = ["Grin Developers <mimblewimble@lists.launchpad.net>"]
|
||||||
description = "APIs for grin, a simple, private and scalable cryptocurrency implementation based on the MimbleWimble chain format."
|
description = "APIs for grin, a simple, private and scalable cryptocurrency implementation based on the MimbleWimble chain format."
|
||||||
license = "Apache-2.0"
|
license = "Apache-2.0"
|
||||||
|
@ -30,9 +30,9 @@ futures = "0.1.21"
|
||||||
rustls = "0.13"
|
rustls = "0.13"
|
||||||
url = "1.7.0"
|
url = "1.7.0"
|
||||||
|
|
||||||
grin_core = { path = "../core", version = "0.4.2" }
|
grin_core = { path = "../core", version = "0.5.0" }
|
||||||
grin_chain = { path = "../chain", version = "0.4.2" }
|
grin_chain = { path = "../chain", version = "0.5.0" }
|
||||||
grin_p2p = { path = "../p2p", version = "0.4.2" }
|
grin_p2p = { path = "../p2p", version = "0.5.0" }
|
||||||
grin_pool = { path = "../pool", version = "0.4.2" }
|
grin_pool = { path = "../pool", version = "0.5.0" }
|
||||||
grin_store = { path = "../store", version = "0.4.2" }
|
grin_store = { path = "../store", version = "0.5.0" }
|
||||||
grin_util = { path = "../util", version = "0.4.2" }
|
grin_util = { path = "../util", version = "0.5.0" }
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "grin_chain"
|
name = "grin_chain"
|
||||||
version = "0.4.2"
|
version = "0.5.0"
|
||||||
authors = ["Grin Developers <mimblewimble@lists.launchpad.net>"]
|
authors = ["Grin Developers <mimblewimble@lists.launchpad.net>"]
|
||||||
description = "Chain implementation for grin, a simple, private and scalable cryptocurrency implementation based on the MimbleWimble chain format."
|
description = "Chain implementation for grin, a simple, private and scalable cryptocurrency implementation based on the MimbleWimble chain format."
|
||||||
license = "Apache-2.0"
|
license = "Apache-2.0"
|
||||||
|
@ -22,10 +22,10 @@ serde_derive = "1"
|
||||||
chrono = "0.4.4"
|
chrono = "0.4.4"
|
||||||
lru-cache = "0.1"
|
lru-cache = "0.1"
|
||||||
|
|
||||||
grin_core = { path = "../core", version = "0.4.2" }
|
grin_core = { path = "../core", version = "0.5.0" }
|
||||||
grin_keychain = { path = "../keychain", version = "0.4.2" }
|
grin_keychain = { path = "../keychain", version = "0.5.0" }
|
||||||
grin_store = { path = "../store", version = "0.4.2" }
|
grin_store = { path = "../store", version = "0.5.0" }
|
||||||
grin_util = { path = "../util", version = "0.4.2" }
|
grin_util = { path = "../util", version = "0.5.0" }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
env_logger = "0.5"
|
env_logger = "0.5"
|
||||||
|
|
|
@ -120,7 +120,7 @@ pub enum ErrorKind {
|
||||||
#[fail(display = "Genesis Block Required")]
|
#[fail(display = "Genesis Block Required")]
|
||||||
GenesisBlockRequired,
|
GenesisBlockRequired,
|
||||||
/// Error from underlying tx handling
|
/// Error from underlying tx handling
|
||||||
#[fail(display = "Transaction Error")]
|
#[fail(display = "Transaction Validation Error: {:?}", _0)]
|
||||||
Transaction(transaction::Error),
|
Transaction(transaction::Error),
|
||||||
/// Anything else
|
/// Anything else
|
||||||
#[fail(display = "Other Error: {}", _0)]
|
#[fail(display = "Other Error: {}", _0)]
|
||||||
|
|
|
@ -77,7 +77,7 @@ fn data_files() {
|
||||||
//new block so chain references should be freed
|
//new block so chain references should be freed
|
||||||
{
|
{
|
||||||
let chain = setup(chain_dir);
|
let chain = setup(chain_dir);
|
||||||
let keychain = ExtKeychain::from_random_seed().unwrap();
|
let keychain = ExtKeychain::from_random_seed(false).unwrap();
|
||||||
|
|
||||||
for n in 1..4 {
|
for n in 1..4 {
|
||||||
let prev = chain.head_header().unwrap();
|
let prev = chain.head_header().unwrap();
|
||||||
|
|
|
@ -58,7 +58,7 @@ fn setup(dir_name: &str, genesis: Block) -> Chain {
|
||||||
#[test]
|
#[test]
|
||||||
fn mine_empty_chain() {
|
fn mine_empty_chain() {
|
||||||
global::set_mining_mode(ChainTypes::AutomatedTesting);
|
global::set_mining_mode(ChainTypes::AutomatedTesting);
|
||||||
let keychain = keychain::ExtKeychain::from_random_seed().unwrap();
|
let keychain = keychain::ExtKeychain::from_random_seed(false).unwrap();
|
||||||
mine_some_on_top(".grin", pow::mine_genesis_block().unwrap(), &keychain);
|
mine_some_on_top(".grin", pow::mine_genesis_block().unwrap(), &keychain);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ fn mine_genesis_reward_chain() {
|
||||||
|
|
||||||
// add coinbase data from the dev genesis block
|
// add coinbase data from the dev genesis block
|
||||||
let mut genesis = genesis::genesis_dev();
|
let mut genesis = genesis::genesis_dev();
|
||||||
let keychain = keychain::ExtKeychain::from_random_seed().unwrap();
|
let keychain = keychain::ExtKeychain::from_random_seed(false).unwrap();
|
||||||
let key_id = keychain::ExtKeychain::derive_key_id(0, 1, 0, 0, 0);
|
let key_id = keychain::ExtKeychain::derive_key_id(0, 1, 0, 0, 0);
|
||||||
let reward = reward::output(&keychain, &key_id, 0).unwrap();
|
let reward = reward::output(&keychain, &key_id, 0).unwrap();
|
||||||
genesis = genesis.with_reward(reward.0, reward.1);
|
genesis = genesis.with_reward(reward.0, reward.1);
|
||||||
|
@ -158,7 +158,7 @@ where
|
||||||
fn mine_forks() {
|
fn mine_forks() {
|
||||||
global::set_mining_mode(ChainTypes::AutomatedTesting);
|
global::set_mining_mode(ChainTypes::AutomatedTesting);
|
||||||
let chain = setup(".grin2", pow::mine_genesis_block().unwrap());
|
let chain = setup(".grin2", pow::mine_genesis_block().unwrap());
|
||||||
let kc = ExtKeychain::from_random_seed().unwrap();
|
let kc = ExtKeychain::from_random_seed(false).unwrap();
|
||||||
|
|
||||||
// add a first block to not fork genesis
|
// add a first block to not fork genesis
|
||||||
let prev = chain.head_header().unwrap();
|
let prev = chain.head_header().unwrap();
|
||||||
|
@ -200,7 +200,7 @@ fn mine_forks() {
|
||||||
#[test]
|
#[test]
|
||||||
fn mine_losing_fork() {
|
fn mine_losing_fork() {
|
||||||
global::set_mining_mode(ChainTypes::AutomatedTesting);
|
global::set_mining_mode(ChainTypes::AutomatedTesting);
|
||||||
let kc = ExtKeychain::from_random_seed().unwrap();
|
let kc = ExtKeychain::from_random_seed(false).unwrap();
|
||||||
let chain = setup(".grin3", pow::mine_genesis_block().unwrap());
|
let chain = setup(".grin3", pow::mine_genesis_block().unwrap());
|
||||||
|
|
||||||
// add a first block we'll be forking from
|
// add a first block we'll be forking from
|
||||||
|
@ -232,7 +232,7 @@ fn mine_losing_fork() {
|
||||||
#[test]
|
#[test]
|
||||||
fn longer_fork() {
|
fn longer_fork() {
|
||||||
global::set_mining_mode(ChainTypes::AutomatedTesting);
|
global::set_mining_mode(ChainTypes::AutomatedTesting);
|
||||||
let kc = ExtKeychain::from_random_seed().unwrap();
|
let kc = ExtKeychain::from_random_seed(false).unwrap();
|
||||||
// to make it easier to compute the txhashset roots in the test, we
|
// to make it easier to compute the txhashset roots in the test, we
|
||||||
// prepare 2 chains, the 2nd will be have the forked blocks we can
|
// prepare 2 chains, the 2nd will be have the forked blocks we can
|
||||||
// then send back on the 1st
|
// then send back on the 1st
|
||||||
|
@ -275,7 +275,7 @@ fn spend_in_fork_and_compact() {
|
||||||
util::init_test_logger();
|
util::init_test_logger();
|
||||||
let chain = setup(".grin6", pow::mine_genesis_block().unwrap());
|
let chain = setup(".grin6", pow::mine_genesis_block().unwrap());
|
||||||
let prev = chain.head_header().unwrap();
|
let prev = chain.head_header().unwrap();
|
||||||
let kc = ExtKeychain::from_random_seed().unwrap();
|
let kc = ExtKeychain::from_random_seed(false).unwrap();
|
||||||
|
|
||||||
let mut fork_head = prev;
|
let mut fork_head = prev;
|
||||||
|
|
||||||
|
@ -404,7 +404,7 @@ fn output_header_mappings() {
|
||||||
".grin_header_for_output",
|
".grin_header_for_output",
|
||||||
pow::mine_genesis_block().unwrap(),
|
pow::mine_genesis_block().unwrap(),
|
||||||
);
|
);
|
||||||
let keychain = ExtKeychain::from_random_seed().unwrap();
|
let keychain = ExtKeychain::from_random_seed(false).unwrap();
|
||||||
let mut reward_outputs = vec![];
|
let mut reward_outputs = vec![];
|
||||||
|
|
||||||
for n in 1..15 {
|
for n in 1..15 {
|
||||||
|
|
|
@ -51,7 +51,7 @@ fn test_various_store_indices() {
|
||||||
let chain_dir = ".grin_idx_1";
|
let chain_dir = ".grin_idx_1";
|
||||||
clean_output_dir(chain_dir);
|
clean_output_dir(chain_dir);
|
||||||
|
|
||||||
let keychain = ExtKeychain::from_random_seed().unwrap();
|
let keychain = ExtKeychain::from_random_seed(false).unwrap();
|
||||||
let key_id = ExtKeychainPath::new(1, 1, 0, 0, 0).to_identifier();
|
let key_id = ExtKeychainPath::new(1, 1, 0, 0, 0).to_identifier();
|
||||||
let db_env = Arc::new(store::new_env(chain_dir.to_string()));
|
let db_env = Arc::new(store::new_env(chain_dir.to_string()));
|
||||||
|
|
||||||
|
|
|
@ -60,7 +60,7 @@ fn test_coinbase_maturity() {
|
||||||
|
|
||||||
let prev = chain.head_header().unwrap();
|
let prev = chain.head_header().unwrap();
|
||||||
|
|
||||||
let keychain = ExtKeychain::from_random_seed().unwrap();
|
let keychain = ExtKeychain::from_random_seed(false).unwrap();
|
||||||
let key_id1 = ExtKeychainPath::new(1, 1, 0, 0, 0).to_identifier();
|
let key_id1 = ExtKeychainPath::new(1, 1, 0, 0, 0).to_identifier();
|
||||||
let key_id2 = ExtKeychainPath::new(1, 2, 0, 0, 0).to_identifier();
|
let key_id2 = ExtKeychainPath::new(1, 2, 0, 0, 0).to_identifier();
|
||||||
let key_id3 = ExtKeychainPath::new(1, 3, 0, 0, 0).to_identifier();
|
let key_id3 = ExtKeychainPath::new(1, 3, 0, 0, 0).to_identifier();
|
||||||
|
@ -142,7 +142,7 @@ fn test_coinbase_maturity() {
|
||||||
for _ in 0..3 {
|
for _ in 0..3 {
|
||||||
let prev = chain.head_header().unwrap();
|
let prev = chain.head_header().unwrap();
|
||||||
|
|
||||||
let keychain = ExtKeychain::from_random_seed().unwrap();
|
let keychain = ExtKeychain::from_random_seed(false).unwrap();
|
||||||
let pk = ExtKeychainPath::new(1, 1, 0, 0, 0).to_identifier();
|
let pk = ExtKeychainPath::new(1, 1, 0, 0, 0).to_identifier();
|
||||||
|
|
||||||
let reward = libtx::reward::output(&keychain, &pk, 0).unwrap();
|
let reward = libtx::reward::output(&keychain, &pk, 0).unwrap();
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "grin_config"
|
name = "grin_config"
|
||||||
version = "0.4.2"
|
version = "0.5.0"
|
||||||
authors = ["Grin Developers <mimblewimble@lists.launchpad.net>"]
|
authors = ["Grin Developers <mimblewimble@lists.launchpad.net>"]
|
||||||
description = "Configuration for grin, a simple, private and scalable cryptocurrency implementation based on the MimbleWimble chain format."
|
description = "Configuration for grin, a simple, private and scalable cryptocurrency implementation based on the MimbleWimble chain format."
|
||||||
license = "Apache-2.0"
|
license = "Apache-2.0"
|
||||||
|
@ -16,10 +16,11 @@ serde_derive = "1"
|
||||||
toml = "0.4"
|
toml = "0.4"
|
||||||
dirs = "1.0.3"
|
dirs = "1.0.3"
|
||||||
|
|
||||||
grin_servers = { path = "../servers", version = "0.4.2" }
|
grin_core = { path = "../core", version = "0.5.0" }
|
||||||
grin_p2p = { path = "../p2p", version = "0.4.2" }
|
grin_servers = { path = "../servers", version = "0.5.0" }
|
||||||
grin_util = { path = "../util", version = "0.4.2" }
|
grin_p2p = { path = "../p2p", version = "0.5.0" }
|
||||||
grin_wallet = { path = "../wallet", version = "0.4.2" }
|
grin_util = { path = "../util", version = "0.5.0" }
|
||||||
|
grin_wallet = { path = "../wallet", version = "0.5.0" }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
pretty_assertions = "0.5.1"
|
pretty_assertions = "0.5.1"
|
||||||
|
|
|
@ -168,7 +168,7 @@ fn comments() -> HashMap<String, String> {
|
||||||
retval.insert(
|
retval.insert(
|
||||||
"[server.p2p_config]".to_string(),
|
"[server.p2p_config]".to_string(),
|
||||||
"#test miner wallet URL (burns if this doesn't exist)
|
"#test miner wallet URL (burns if this doesn't exist)
|
||||||
#test_miner_wallet_url = \"http://127.0.0.1:13415\"
|
#test_miner_wallet_url = \"http://127.0.0.1:3415\"
|
||||||
|
|
||||||
#########################################
|
#########################################
|
||||||
### SERVER P2P CONFIGURATION ###
|
### SERVER P2P CONFIGURATION ###
|
||||||
|
@ -208,15 +208,15 @@ fn comments() -> HashMap<String, String> {
|
||||||
"[server.p2p_config.capabilities]".to_string(),
|
"[server.p2p_config.capabilities]".to_string(),
|
||||||
"#If the seeding type is List, the list of peers to connect to can
|
"#If the seeding type is List, the list of peers to connect to can
|
||||||
#be specified as follows:
|
#be specified as follows:
|
||||||
#seeds = [\"192.168.0.1:13414\",\"192.168.0.2:13414\"]
|
#seeds = [\"192.168.0.1:3414\",\"192.168.0.2:3414\"]
|
||||||
|
|
||||||
#hardcoded peer lists for allow/deny
|
#hardcoded peer lists for allow/deny
|
||||||
#will *only* connect to peers in allow list
|
#will *only* connect to peers in allow list
|
||||||
#peers_allow = [\"192.168.0.1:13414\", \"192.168.0.2:13414\"]
|
#peers_allow = [\"192.168.0.1:3414\", \"192.168.0.2:3414\"]
|
||||||
#will *never* connect to peers in deny list
|
#will *never* connect to peers in deny list
|
||||||
#peers_deny = [\"192.168.0.3:13414\", \"192.168.0.4:13414\"]
|
#peers_deny = [\"192.168.0.3:3414\", \"192.168.0.4:3414\"]
|
||||||
#a list of preferred peers to connect to
|
#a list of preferred peers to connect to
|
||||||
#peers_preferred = [\"192.168.0.1:13414\",\"192.168.0.2:13414\"]
|
#peers_preferred = [\"192.168.0.1:3414\",\"192.168.0.2:3414\"]
|
||||||
|
|
||||||
#how long a banned peer should stay banned
|
#how long a banned peer should stay banned
|
||||||
#ban_window = 10800
|
#ban_window = 10800
|
||||||
|
|
|
@ -26,6 +26,8 @@ use std::path::PathBuf;
|
||||||
use toml;
|
use toml;
|
||||||
|
|
||||||
use crate::comments::insert_comments;
|
use crate::comments::insert_comments;
|
||||||
|
use crate::core::global;
|
||||||
|
use crate::p2p;
|
||||||
use crate::servers::ServerConfig;
|
use crate::servers::ServerConfig;
|
||||||
use crate::types::{
|
use crate::types::{
|
||||||
ConfigError, ConfigMembers, GlobalConfig, GlobalWalletConfig, GlobalWalletConfigMembers,
|
ConfigError, ConfigMembers, GlobalConfig, GlobalWalletConfig, GlobalWalletConfigMembers,
|
||||||
|
@ -45,21 +47,14 @@ const GRIN_CHAIN_DIR: &'static str = "chain_data";
|
||||||
const GRIN_WALLET_DIR: &'static str = "wallet_data";
|
const GRIN_WALLET_DIR: &'static str = "wallet_data";
|
||||||
const API_SECRET_FILE_NAME: &'static str = ".api_secret";
|
const API_SECRET_FILE_NAME: &'static str = ".api_secret";
|
||||||
|
|
||||||
fn get_grin_path() -> Result<PathBuf, ConfigError> {
|
fn get_grin_path(chain_type: &global::ChainTypes) -> Result<PathBuf, ConfigError> {
|
||||||
// Check if grin dir exists
|
// Check if grin dir exists
|
||||||
let grin_path = {
|
let mut grin_path = match dirs::home_dir() {
|
||||||
match dirs::home_dir() {
|
Some(p) => p,
|
||||||
Some(mut p) => {
|
None => PathBuf::new(),
|
||||||
p.push(GRIN_HOME);
|
|
||||||
p
|
|
||||||
}
|
|
||||||
None => {
|
|
||||||
let mut pb = PathBuf::new();
|
|
||||||
pb.push(GRIN_HOME);
|
|
||||||
pb
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
grin_path.push(GRIN_HOME);
|
||||||
|
grin_path.push(chain_type.shortname());
|
||||||
// Create if the default path doesn't exist
|
// Create if the default path doesn't exist
|
||||||
if !grin_path.exists() {
|
if !grin_path.exists() {
|
||||||
fs::create_dir_all(grin_path.clone())?;
|
fs::create_dir_all(grin_path.clone())?;
|
||||||
|
@ -107,8 +102,8 @@ fn check_api_secret(api_secret_path: &PathBuf) -> Result<(), ConfigError> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check that the api secret file exists and is valid
|
/// Check that the api secret file exists and is valid
|
||||||
fn check_api_secret_file() -> Result<(), ConfigError> {
|
fn check_api_secret_file(chain_type: &global::ChainTypes) -> Result<(), ConfigError> {
|
||||||
let grin_path = get_grin_path()?;
|
let grin_path = get_grin_path(chain_type)?;
|
||||||
let mut api_secret_path = grin_path.clone();
|
let mut api_secret_path = grin_path.clone();
|
||||||
api_secret_path.push(API_SECRET_FILE_NAME);
|
api_secret_path.push(API_SECRET_FILE_NAME);
|
||||||
if !api_secret_path.exists() {
|
if !api_secret_path.exists() {
|
||||||
|
@ -119,14 +114,14 @@ fn check_api_secret_file() -> Result<(), ConfigError> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Handles setup and detection of paths for node
|
/// Handles setup and detection of paths for node
|
||||||
pub fn initial_setup_server() -> Result<GlobalConfig, ConfigError> {
|
pub fn initial_setup_server(chain_type: &global::ChainTypes) -> Result<GlobalConfig, ConfigError> {
|
||||||
check_api_secret_file()?;
|
check_api_secret_file(chain_type)?;
|
||||||
// Use config file if current directory if it exists, .grin home otherwise
|
// Use config file if current directory if it exists, .grin home otherwise
|
||||||
if let Some(p) = check_config_current_dir(SERVER_CONFIG_FILE_NAME) {
|
if let Some(p) = check_config_current_dir(SERVER_CONFIG_FILE_NAME) {
|
||||||
GlobalConfig::new(p.to_str().unwrap())
|
GlobalConfig::new(p.to_str().unwrap())
|
||||||
} else {
|
} else {
|
||||||
// Check if grin dir exists
|
// Check if grin dir exists
|
||||||
let grin_path = get_grin_path()?;
|
let grin_path = get_grin_path(chain_type)?;
|
||||||
|
|
||||||
// Get path to default config file
|
// Get path to default config file
|
||||||
let mut config_path = grin_path.clone();
|
let mut config_path = grin_path.clone();
|
||||||
|
@ -134,7 +129,7 @@ pub fn initial_setup_server() -> Result<GlobalConfig, ConfigError> {
|
||||||
|
|
||||||
// Spit it out if it doesn't exist
|
// Spit it out if it doesn't exist
|
||||||
if !config_path.exists() {
|
if !config_path.exists() {
|
||||||
let mut default_config = GlobalConfig::default();
|
let mut default_config = GlobalConfig::for_chain(chain_type);
|
||||||
// update paths relative to current dir
|
// update paths relative to current dir
|
||||||
default_config.update_paths(&grin_path);
|
default_config.update_paths(&grin_path);
|
||||||
default_config.write_to_file(config_path.to_str().unwrap())?;
|
default_config.write_to_file(config_path.to_str().unwrap())?;
|
||||||
|
@ -145,14 +140,16 @@ pub fn initial_setup_server() -> Result<GlobalConfig, ConfigError> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Handles setup and detection of paths for wallet
|
/// Handles setup and detection of paths for wallet
|
||||||
pub fn initial_setup_wallet() -> Result<GlobalWalletConfig, ConfigError> {
|
pub fn initial_setup_wallet(
|
||||||
check_api_secret_file()?;
|
chain_type: &global::ChainTypes,
|
||||||
|
) -> Result<GlobalWalletConfig, ConfigError> {
|
||||||
|
check_api_secret_file(chain_type)?;
|
||||||
// Use config file if current directory if it exists, .grin home otherwise
|
// Use config file if current directory if it exists, .grin home otherwise
|
||||||
if let Some(p) = check_config_current_dir(WALLET_CONFIG_FILE_NAME) {
|
if let Some(p) = check_config_current_dir(WALLET_CONFIG_FILE_NAME) {
|
||||||
GlobalWalletConfig::new(p.to_str().unwrap())
|
GlobalWalletConfig::new(p.to_str().unwrap())
|
||||||
} else {
|
} else {
|
||||||
// Check if grin dir exists
|
// Check if grin dir exists
|
||||||
let grin_path = get_grin_path()?;
|
let grin_path = get_grin_path(chain_type)?;
|
||||||
|
|
||||||
// Get path to default config file
|
// Get path to default config file
|
||||||
let mut config_path = grin_path.clone();
|
let mut config_path = grin_path.clone();
|
||||||
|
@ -160,7 +157,7 @@ pub fn initial_setup_wallet() -> Result<GlobalWalletConfig, ConfigError> {
|
||||||
|
|
||||||
// Spit it out if it doesn't exist
|
// Spit it out if it doesn't exist
|
||||||
if !config_path.exists() {
|
if !config_path.exists() {
|
||||||
let mut default_config = GlobalWalletConfig::default();
|
let mut default_config = GlobalWalletConfig::for_chain(chain_type);
|
||||||
// update paths relative to current dir
|
// update paths relative to current dir
|
||||||
default_config.update_paths(&grin_path);
|
default_config.update_paths(&grin_path);
|
||||||
default_config.write_to_file(config_path.to_str().unwrap())?;
|
default_config.write_to_file(config_path.to_str().unwrap())?;
|
||||||
|
@ -208,6 +205,51 @@ impl Default for GlobalWalletConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GlobalConfig {
|
impl GlobalConfig {
|
||||||
|
/// Same as GlobalConfig::default() but further tweaks parameters to
|
||||||
|
/// apply defaults for each chain type
|
||||||
|
pub fn for_chain(chain_type: &global::ChainTypes) -> GlobalConfig {
|
||||||
|
let mut defaults_conf = GlobalConfig::default();
|
||||||
|
let mut defaults = &mut defaults_conf.members.as_mut().unwrap().server;
|
||||||
|
defaults.chain_type = chain_type.clone();
|
||||||
|
|
||||||
|
match *chain_type {
|
||||||
|
global::ChainTypes::Mainnet => {}
|
||||||
|
global::ChainTypes::Floonet => {
|
||||||
|
defaults.api_http_addr = "127.0.0.1:13413".to_owned();
|
||||||
|
defaults.p2p_config.port = 13414;
|
||||||
|
defaults
|
||||||
|
.stratum_mining_config
|
||||||
|
.as_mut()
|
||||||
|
.unwrap()
|
||||||
|
.stratum_server_addr = Some("127.0.0.1:13416".to_owned());
|
||||||
|
defaults
|
||||||
|
.stratum_mining_config
|
||||||
|
.as_mut()
|
||||||
|
.unwrap()
|
||||||
|
.wallet_listener_url = "http://127.0.0.1:13415".to_owned();
|
||||||
|
}
|
||||||
|
global::ChainTypes::UserTesting => {
|
||||||
|
defaults.api_http_addr = "127.0.0.1:23413".to_owned();
|
||||||
|
defaults.p2p_config.port = 23414;
|
||||||
|
defaults.p2p_config.seeding_type = p2p::Seeding::None;
|
||||||
|
defaults
|
||||||
|
.stratum_mining_config
|
||||||
|
.as_mut()
|
||||||
|
.unwrap()
|
||||||
|
.stratum_server_addr = Some("127.0.0.1:23416".to_owned());
|
||||||
|
defaults
|
||||||
|
.stratum_mining_config
|
||||||
|
.as_mut()
|
||||||
|
.unwrap()
|
||||||
|
.wallet_listener_url = "http://127.0.0.1:23415".to_owned();
|
||||||
|
}
|
||||||
|
global::ChainTypes::AutomatedTesting => {
|
||||||
|
panic!("Can't run automated testing directly");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
defaults_conf
|
||||||
|
}
|
||||||
|
|
||||||
/// Requires the path to a config file
|
/// Requires the path to a config file
|
||||||
pub fn new(file_path: &str) -> Result<GlobalConfig, ConfigError> {
|
pub fn new(file_path: &str) -> Result<GlobalConfig, ConfigError> {
|
||||||
let mut return_value = GlobalConfig::default();
|
let mut return_value = GlobalConfig::default();
|
||||||
|
@ -315,6 +357,29 @@ impl GlobalConfig {
|
||||||
|
|
||||||
/// TODO: Properly templatize these structs (if it's worth the effort)
|
/// TODO: Properly templatize these structs (if it's worth the effort)
|
||||||
impl GlobalWalletConfig {
|
impl GlobalWalletConfig {
|
||||||
|
/// Same as GlobalConfig::default() but further tweaks parameters to
|
||||||
|
/// apply defaults for each chain type
|
||||||
|
pub fn for_chain(chain_type: &global::ChainTypes) -> GlobalWalletConfig {
|
||||||
|
let mut defaults_conf = GlobalWalletConfig::default();
|
||||||
|
let mut defaults = &mut defaults_conf.members.as_mut().unwrap().wallet;
|
||||||
|
defaults.chain_type = Some(chain_type.clone());
|
||||||
|
|
||||||
|
match *chain_type {
|
||||||
|
global::ChainTypes::Mainnet => {}
|
||||||
|
global::ChainTypes::Floonet => {
|
||||||
|
defaults.api_listen_port = 13415;
|
||||||
|
defaults.check_node_api_http_addr = "http://127.0.0.1:13413".to_owned();
|
||||||
|
}
|
||||||
|
global::ChainTypes::UserTesting => {
|
||||||
|
defaults.api_listen_port = 23415;
|
||||||
|
defaults.check_node_api_http_addr = "http://127.0.0.1:23413".to_owned();
|
||||||
|
}
|
||||||
|
global::ChainTypes::AutomatedTesting => {
|
||||||
|
panic!("Can't run automated testing directly");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
defaults_conf
|
||||||
|
}
|
||||||
/// Requires the path to a config file
|
/// Requires the path to a config file
|
||||||
pub fn new(file_path: &str) -> Result<GlobalWalletConfig, ConfigError> {
|
pub fn new(file_path: &str) -> Result<GlobalWalletConfig, ConfigError> {
|
||||||
let mut return_value = GlobalWalletConfig::default();
|
let mut return_value = GlobalWalletConfig::default();
|
||||||
|
|
|
@ -26,6 +26,8 @@ use dirs;
|
||||||
extern crate serde_derive;
|
extern crate serde_derive;
|
||||||
use toml;
|
use toml;
|
||||||
|
|
||||||
|
use grin_core as core;
|
||||||
|
use grin_p2p as p2p;
|
||||||
use grin_servers as servers;
|
use grin_servers as servers;
|
||||||
use grin_util as util;
|
use grin_util as util;
|
||||||
use grin_wallet as wallet;
|
use grin_wallet as wallet;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "grin_core"
|
name = "grin_core"
|
||||||
version = "0.4.2"
|
version = "0.5.0"
|
||||||
authors = ["Grin Developers <mimblewimble@lists.launchpad.net>"]
|
authors = ["Grin Developers <mimblewimble@lists.launchpad.net>"]
|
||||||
description = "Chain implementation for grin, a simple, private and scalable cryptocurrency implementation based on the MimbleWimble chain format."
|
description = "Chain implementation for grin, a simple, private and scalable cryptocurrency implementation based on the MimbleWimble chain format."
|
||||||
license = "Apache-2.0"
|
license = "Apache-2.0"
|
||||||
|
@ -28,5 +28,5 @@ uuid = { version = "0.6", features = ["serde", "v4"] }
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
chrono = "0.4.4"
|
chrono = "0.4.4"
|
||||||
|
|
||||||
grin_keychain = { path = "../keychain", version = "0.4.2" }
|
grin_keychain = { path = "../keychain", version = "0.5.0" }
|
||||||
grin_util = { path = "../util", version = "0.4.2" }
|
grin_util = { path = "../util", version = "0.5.0" }
|
||||||
|
|
|
@ -231,7 +231,8 @@ impl HeaderInfo {
|
||||||
timestamp,
|
timestamp,
|
||||||
difficulty,
|
difficulty,
|
||||||
secondary_scaling: global::initial_graph_weight(),
|
secondary_scaling: global::initial_graph_weight(),
|
||||||
is_secondary: global::is_mainnet(), // floonet launched with false:-(
|
|
||||||
|
is_secondary: true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -242,7 +243,7 @@ impl HeaderInfo {
|
||||||
timestamp: 1,
|
timestamp: 1,
|
||||||
difficulty,
|
difficulty,
|
||||||
secondary_scaling,
|
secondary_scaling,
|
||||||
is_secondary: false,
|
is_secondary: true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1349,37 +1349,31 @@ impl From<Output> for OutputIdentifier {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Construct msg from tx fee, lock_height and kernel features.
|
/// Construct msg from tx fee, lock_height and kernel features.
|
||||||
/// In testnet4 we did not include the kernel features in the message being signed.
|
|
||||||
/// In mainnet we changed this to include features and we hash (fee || lock_height || features)
|
|
||||||
/// to produce a 32 byte message to sign.
|
|
||||||
///
|
///
|
||||||
/// testnet4: msg = (fee || lock_height)
|
/// msg = hash(features) for coinbase kernels
|
||||||
/// mainnet: msg = hash(features) for coinbase kernels
|
/// hash(features || fee) for plain kernels
|
||||||
/// hash(features || fee) for plain kernels
|
/// hash(features || fee || lock_height) for height locked kernels
|
||||||
/// hash(features || fee || lock_height) for height locked kernels
|
|
||||||
///
|
///
|
||||||
pub fn kernel_sig_msg(
|
pub fn kernel_sig_msg(
|
||||||
fee: u64,
|
fee: u64,
|
||||||
lock_height: u64,
|
lock_height: u64,
|
||||||
features: KernelFeatures,
|
features: KernelFeatures,
|
||||||
) -> Result<secp::Message, Error> {
|
) -> Result<secp::Message, Error> {
|
||||||
if features.is_coinbase() && fee != 0 || !features.is_height_locked() && lock_height != 0 {
|
let valid_features = match features {
|
||||||
|
KernelFeatures::COINBASE => fee == 0 && lock_height == 0,
|
||||||
|
KernelFeatures::PLAIN => lock_height == 0,
|
||||||
|
KernelFeatures::HEIGHT_LOCKED => true,
|
||||||
|
_ => false,
|
||||||
|
};
|
||||||
|
if !valid_features {
|
||||||
return Err(Error::InvalidKernelFeatures);
|
return Err(Error::InvalidKernelFeatures);
|
||||||
}
|
}
|
||||||
let msg = if global::is_testnet() {
|
let hash = match features {
|
||||||
let mut bytes = [0; 32];
|
KernelFeatures::COINBASE => (features).hash(),
|
||||||
BigEndian::write_u64(&mut bytes[16..24], fee);
|
KernelFeatures::PLAIN => (features, fee).hash(),
|
||||||
BigEndian::write_u64(&mut bytes[24..], lock_height);
|
_ => (features, fee, lock_height).hash(),
|
||||||
secp::Message::from_slice(&bytes)?
|
|
||||||
} else {
|
|
||||||
let hash = match features {
|
|
||||||
KernelFeatures::COINBASE => (features).hash(),
|
|
||||||
KernelFeatures::PLAIN => (features, fee).hash(),
|
|
||||||
_ => (features, fee, lock_height).hash(),
|
|
||||||
};
|
|
||||||
secp::Message::from_slice(&hash.as_bytes())?
|
|
||||||
};
|
};
|
||||||
Ok(msg)
|
Ok(secp::Message::from_slice(&hash.as_bytes())?)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// kernel features as determined by lock height
|
/// kernel features as determined by lock height
|
||||||
|
@ -1401,7 +1395,7 @@ mod test {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_kernel_ser_deser() {
|
fn test_kernel_ser_deser() {
|
||||||
let keychain = ExtKeychain::from_random_seed().unwrap();
|
let keychain = ExtKeychain::from_random_seed(false).unwrap();
|
||||||
let key_id = ExtKeychain::derive_key_id(1, 1, 0, 0, 0);
|
let key_id = ExtKeychain::derive_key_id(1, 1, 0, 0, 0);
|
||||||
let commit = keychain.commit(5, &key_id).unwrap();
|
let commit = keychain.commit(5, &key_id).unwrap();
|
||||||
|
|
||||||
|
@ -1446,7 +1440,7 @@ mod test {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn commit_consistency() {
|
fn commit_consistency() {
|
||||||
let keychain = ExtKeychain::from_seed(&[0; 32]).unwrap();
|
let keychain = ExtKeychain::from_seed(&[0; 32], false).unwrap();
|
||||||
let key_id = ExtKeychain::derive_key_id(1, 1, 0, 0, 0);
|
let key_id = ExtKeychain::derive_key_id(1, 1, 0, 0, 0);
|
||||||
|
|
||||||
let commit = keychain.commit(1003, &key_id).unwrap();
|
let commit = keychain.commit(1003, &key_id).unwrap();
|
||||||
|
@ -1459,7 +1453,7 @@ mod test {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn input_short_id() {
|
fn input_short_id() {
|
||||||
let keychain = ExtKeychain::from_seed(&[0; 32]).unwrap();
|
let keychain = ExtKeychain::from_seed(&[0; 32], false).unwrap();
|
||||||
let key_id = ExtKeychain::derive_key_id(1, 1, 0, 0, 0);
|
let key_id = ExtKeychain::derive_key_id(1, 1, 0, 0, 0);
|
||||||
let commit = keychain.commit(5, &key_id).unwrap();
|
let commit = keychain.commit(5, &key_id).unwrap();
|
||||||
|
|
||||||
|
|
|
@ -51,21 +51,21 @@ pub fn genesis_dev() -> core::Block {
|
||||||
pub fn genesis_floo() -> core::Block {
|
pub fn genesis_floo() -> core::Block {
|
||||||
let gen = core::Block::with_header(core::BlockHeader {
|
let gen = core::Block::with_header(core::BlockHeader {
|
||||||
height: 0,
|
height: 0,
|
||||||
timestamp: Utc.ymd(2018, 12, 20).and_hms(20, 58, 32),
|
timestamp: Utc.ymd(2018, 12, 28).and_hms(20, 48, 4),
|
||||||
prev_root: Hash::from_hex(
|
prev_root: Hash::from_hex(
|
||||||
"ae144568a9ec32faf57e9ca5b5f0997d33f30bd3352fd84c953e6526d847c26b",
|
"00000000000000000017ff4903ef366c8f62e3151ba74e41b8332a126542f538",
|
||||||
)
|
)
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
output_root: Hash::from_hex(
|
output_root: Hash::from_hex(
|
||||||
"47d2570266451203c62cd003c706e3ec37e9cb4292316744abfa68a1b133bc1c",
|
"73b5e0a05ea9e1e4e33b8f1c723bc5c10d17f07042c2af7644f4dbb61f4bc556",
|
||||||
)
|
)
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
range_proof_root: Hash::from_hex(
|
range_proof_root: Hash::from_hex(
|
||||||
"53ea93e80fe37e9a0cbb9c1a1ddf467213922481a4435921aacf55ffb3f388fc",
|
"667a3ba22f237a875f67c9933037c8564097fa57a3e75be507916de28fc0da26",
|
||||||
)
|
)
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
kernel_root: Hash::from_hex(
|
kernel_root: Hash::from_hex(
|
||||||
"3ff7655b2846a1313dd72e1c516a2fa262638fabc8e0d4c1dddf80773bbd472d",
|
"cfdddfe2d938d0026f8b1304442655bbdddde175ff45ddf44cb03bcb0071a72d",
|
||||||
)
|
)
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
total_kernel_offset: BlindingFactor::from_hex(
|
total_kernel_offset: BlindingFactor::from_hex(
|
||||||
|
@ -75,17 +75,17 @@ pub fn genesis_floo() -> core::Block {
|
||||||
output_mmr_size: 1,
|
output_mmr_size: 1,
|
||||||
kernel_mmr_size: 1,
|
kernel_mmr_size: 1,
|
||||||
pow: ProofOfWork {
|
pow: ProofOfWork {
|
||||||
total_difficulty: Difficulty::from_num(10_u64.pow(6)),
|
total_difficulty: Difficulty::from_num(10_u64.pow(5)),
|
||||||
secondary_scaling: 1856,
|
secondary_scaling: 1856,
|
||||||
nonce: 22,
|
nonce: 23,
|
||||||
proof: Proof {
|
proof: Proof {
|
||||||
nonces: vec![
|
nonces: vec![
|
||||||
48398361, 50434294, 73758991, 93493375, 94716564, 101961133, 153506566,
|
16994232, 22975978, 32664019, 44016212, 50238216, 57272481, 85779161,
|
||||||
159476458, 164019912, 208165915, 216747111, 218441011, 221663358, 262514197,
|
124272202, 125203242, 133907662, 140522149, 145870823, 147481297, 164952795,
|
||||||
264746362, 278423427, 282069592, 284508695, 297003554, 327321117, 327780367,
|
177186722, 183382201, 197418356, 211393794, 239282197, 239323031, 250757611,
|
||||||
329474453, 333639856, 356316379, 366419120, 381872178, 386038638, 389726932,
|
281414565, 305112109, 308151499, 357235186, 374041407, 389924708, 390768911,
|
||||||
390055244, 392425788, 399530286, 426997994, 436531599, 456084550, 456375883,
|
401322239, 401886855, 406986280, 416797005, 418935317, 429007407, 439527429,
|
||||||
459156409, 474067792, 480904139, 487380747, 489307817, 496780560, 530227836,
|
484809502, 486257104, 495589543, 495892390, 525019296, 529899691, 531685572,
|
||||||
],
|
],
|
||||||
edge_bits: 29,
|
edge_bits: 29,
|
||||||
},
|
},
|
||||||
|
@ -98,15 +98,15 @@ pub fn genesis_floo() -> core::Block {
|
||||||
lock_height: 0,
|
lock_height: 0,
|
||||||
excess: Commitment::from_vec(
|
excess: Commitment::from_vec(
|
||||||
util::from_hex(
|
util::from_hex(
|
||||||
"0817a9e97a070ba5f9fa185c093b4b13b262ed4b4712b6f7c92881b27168f9a2cb".to_string(),
|
"08df2f1d996cee37715d9ac0a0f3b13aae508d1101945acb8044954aee30960be9".to_string(),
|
||||||
)
|
)
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
),
|
),
|
||||||
excess_sig: Signature::from_raw_data(&[
|
excess_sig: Signature::from_raw_data(&[
|
||||||
172, 131, 105, 224, 31, 11, 0, 70, 109, 54, 230, 184, 177, 138, 46, 137, 202, 215, 152,
|
25, 176, 52, 246, 172, 1, 12, 220, 247, 111, 73, 101, 13, 16, 157, 130, 110, 196, 123,
|
||||||
37, 192, 132, 88, 254, 110, 76, 57, 32, 42, 13, 19, 89, 82, 89, 116, 66, 30, 132, 120,
|
217, 246, 137, 45, 110, 106, 186, 0, 151, 255, 193, 233, 178, 103, 26, 210, 215, 200,
|
||||||
148, 122, 100, 97, 38, 141, 219, 57, 184, 171, 130, 213, 235, 83, 202, 69, 13, 213, 60,
|
89, 146, 188, 9, 161, 28, 212, 227, 143, 82, 54, 5, 223, 16, 65, 237, 132, 196, 241,
|
||||||
150, 172, 33, 37, 209, 57,
|
39, 76, 133, 45, 252, 131, 88, 0,
|
||||||
])
|
])
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
};
|
};
|
||||||
|
@ -114,51 +114,51 @@ pub fn genesis_floo() -> core::Block {
|
||||||
features: core::OutputFeatures::COINBASE,
|
features: core::OutputFeatures::COINBASE,
|
||||||
commit: Commitment::from_vec(
|
commit: Commitment::from_vec(
|
||||||
util::from_hex(
|
util::from_hex(
|
||||||
"08f5523cbd8b2e1dae3eefdd9dd1069e0c8a7f055a0611da79f42530c5de0d044b".to_string(),
|
"08c12007af16d1ee55fffe92cef808c77e318dae70c3bc70cb6361f49d517f1b68".to_string(),
|
||||||
)
|
)
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
),
|
),
|
||||||
proof: RangeProof {
|
proof: RangeProof {
|
||||||
plen: SINGLE_BULLET_PROOF_SIZE,
|
plen: SINGLE_BULLET_PROOF_SIZE,
|
||||||
proof: [
|
proof: [
|
||||||
47, 196, 194, 238, 233, 164, 218, 64, 54, 92, 83, 248, 225, 116, 189, 225, 202, 66,
|
159, 156, 202, 179, 128, 169, 14, 227, 176, 79, 118, 180, 62, 164, 2, 234, 123, 30,
|
||||||
213, 63, 195, 209, 238, 189, 153, 198, 231, 219, 3, 146, 102, 67, 26, 7, 199, 150,
|
77, 126, 232, 124, 42, 186, 239, 208, 21, 217, 228, 246, 148, 74, 100, 25, 247,
|
||||||
160, 244, 48, 166, 113, 6, 241, 49, 133, 248, 201, 80, 34, 19, 118, 249, 44, 213,
|
251, 82, 100, 37, 16, 146, 122, 164, 5, 2, 165, 212, 192, 221, 167, 199, 8, 231,
|
||||||
215, 235, 228, 187, 215, 116, 212, 203, 232, 183, 12, 66, 29, 11, 28, 17, 212, 104,
|
149, 158, 216, 194, 200, 62, 15, 53, 200, 188, 207, 0, 79, 211, 88, 194, 211, 54,
|
||||||
126, 203, 103, 60, 176, 149, 182, 206, 70, 138, 180, 213, 76, 99, 25, 184, 40, 177,
|
1, 206, 53, 72, 118, 155, 184, 233, 166, 245, 224, 16, 254, 209, 235, 153, 85, 53,
|
||||||
197, 179, 71, 63, 19, 72, 253, 129, 115, 107, 90, 249, 39, 108, 134, 10, 231, 172,
|
145, 33, 186, 218, 118, 144, 35, 189, 241, 63, 229, 52, 237, 231, 39, 176, 202, 93,
|
||||||
172, 59, 207, 118, 175, 124, 197, 132, 73, 154, 148, 8, 73, 26, 231, 75, 24, 134,
|
247, 85, 131, 16, 193, 247, 180, 33, 138, 255, 102, 190, 213, 129, 174, 182, 167,
|
||||||
199, 93, 15, 43, 45, 49, 69, 167, 194, 23, 114, 16, 117, 209, 127, 123, 18, 209,
|
3, 126, 184, 221, 99, 114, 238, 219, 157, 125, 230, 179, 160, 89, 202, 230, 16, 91,
|
||||||
12, 34, 219, 196, 37, 7, 226, 132, 70, 111, 113, 164, 203, 175, 105, 175, 196, 62,
|
199, 57, 158, 225, 142, 125, 12, 211, 164, 78, 9, 4, 155, 106, 157, 41, 233, 188,
|
||||||
225, 138, 162, 176, 190, 109, 96, 210, 15, 38, 245, 200, 83, 155, 185, 111, 85,
|
237, 205, 184, 53, 0, 190, 24, 215, 42, 44, 184, 120, 58, 196, 198, 190, 114, 50,
|
||||||
234, 6, 3, 246, 98, 175, 127, 94, 65, 29, 78, 27, 53, 32, 230, 85, 91, 195, 112,
|
98, 240, 15, 213, 77, 163, 24, 3, 212, 125, 93, 175, 169, 249, 24, 27, 191, 113,
|
||||||
84, 135, 56, 207, 213, 165, 40, 248, 238, 202, 225, 142, 79, 89, 81, 197, 138, 65,
|
89, 59, 169, 40, 87, 250, 144, 159, 118, 171, 232, 92, 217, 5, 179, 152, 249, 247,
|
||||||
14, 232, 145, 44, 73, 6, 43, 8, 43, 42, 127, 151, 68, 18, 19, 83, 14, 142, 180, 75,
|
71, 239, 26, 180, 82, 177, 226, 132, 185, 3, 33, 162, 120, 98, 87, 109, 57, 100,
|
||||||
25, 4, 97, 166, 237, 212, 187, 106, 154, 36, 223, 231, 177, 58, 70, 1, 195, 113,
|
202, 162, 57, 230, 44, 31, 63, 213, 30, 222, 241, 78, 162, 118, 120, 70, 196, 128,
|
||||||
144, 151, 45, 185, 0, 174, 116, 212, 122, 239, 96, 1, 122, 211, 41, 96, 230, 110,
|
72, 223, 110, 5, 17, 151, 97, 214, 43, 57, 157, 1, 59, 87, 96, 17, 159, 174, 144,
|
||||||
242, 145, 176, 230, 55, 143, 142, 234, 151, 49, 151, 109, 252, 120, 147, 244, 178,
|
217, 159, 87, 36, 113, 41, 155, 186, 252, 162, 46, 22, 80, 133, 3, 113, 248, 11,
|
||||||
73, 196, 221, 150, 85, 69, 113, 50, 166, 92, 91, 98, 188, 77, 76, 48, 192, 112,
|
118, 144, 155, 188, 77, 166, 40, 119, 107, 15, 233, 47, 47, 101, 77, 167, 141, 235,
|
||||||
184, 108, 143, 134, 56, 46, 119, 21, 71, 247, 119, 133, 225, 72, 15, 158, 60, 64,
|
148, 34, 218, 164, 168, 71, 20, 239, 71, 24, 12, 109, 146, 232, 243, 65, 31, 72,
|
||||||
71, 57, 134, 243, 228, 58, 13, 58, 209, 71, 4, 72, 87, 129, 51, 46, 64, 188, 60,
|
186, 131, 190, 43, 227, 157, 41, 49, 126, 136, 51, 41, 50, 213, 37, 186, 223, 87,
|
||||||
157, 56, 120, 23, 2, 47, 143, 79, 176, 54, 3, 47, 227, 124, 70, 242, 8, 59, 113,
|
248, 34, 43, 132, 34, 0, 143, 75, 79, 43, 74, 183, 26, 2, 168, 53, 203, 208, 159,
|
||||||
203, 51, 65, 138, 131, 121, 45, 131, 132, 171, 161, 49, 235, 129, 39, 164, 234, 69,
|
69, 107, 124, 33, 68, 113, 206, 127, 216, 158, 15, 52, 206, 1, 101, 109, 199, 13,
|
||||||
172, 95, 28, 180, 118, 163, 151, 148, 66, 65, 104, 222, 232, 154, 22, 30, 149, 196,
|
131, 122, 29, 131, 133, 125, 219, 70, 69, 144, 133, 68, 233, 67, 203, 132, 160,
|
||||||
214, 163, 93, 76, 128, 142, 233, 106, 171, 213, 148, 59, 101, 56, 22, 127, 232, 4,
|
143, 101, 84, 110, 15, 175, 111, 124, 24, 185, 222, 154, 238, 77, 241, 105, 8, 224,
|
||||||
63, 111, 9, 188, 163, 40, 158, 24, 65, 81, 203, 231, 93, 197, 102, 170, 70, 239,
|
230, 43, 178, 49, 95, 137, 33, 227, 118, 207, 239, 56, 21, 51, 220, 22, 48, 162,
|
||||||
229, 13, 172, 110, 157, 226, 112, 182, 28, 150, 222, 62, 224, 94, 182, 220, 243,
|
22, 118, 229, 215, 248, 112, 198, 126, 180, 27, 161, 237, 56, 2, 220, 129, 126, 11,
|
||||||
236, 62, 156, 129, 220, 127, 155, 141, 0, 243, 159, 113, 28, 158, 95, 205, 35, 72,
|
104, 8, 133, 190, 162, 204, 3, 63, 249, 173, 210, 152, 252, 143, 157, 79, 228, 232,
|
||||||
132, 46, 235, 176, 146, 233, 93, 111, 4, 105, 236, 176, 165, 102, 168, 188, 121,
|
230, 72, 164, 131, 183, 151, 230, 219, 186, 21, 34, 154, 219, 215, 231, 179, 47,
|
||||||
105, 175, 197, 114, 97, 40, 2, 165, 153, 85, 135, 114, 147, 95, 216, 50, 108, 52,
|
217, 44, 115, 203, 157, 35, 195, 113, 235, 194, 102, 96, 205, 24, 221, 213, 147,
|
||||||
225, 186, 215, 110, 122, 230, 14, 246, 141, 180, 41, 22, 132, 58, 8, 31, 187, 221,
|
120, 178, 221, 153, 146, 44, 172, 131, 77, 21, 61, 15, 5, 6, 205, 164, 203, 76,
|
||||||
231, 14, 33, 52, 88, 219, 200, 77, 246, 134, 18, 0, 113, 144, 6, 146, 54, 24, 113,
|
228, 29, 126, 136, 88, 230, 210, 62, 164, 103, 125, 55, 231, 129, 89, 61, 222, 50,
|
||||||
14, 64, 182, 116, 229, 250, 201, 126, 84, 192, 80, 13, 57, 232, 55, 113, 139, 249,
|
71, 71, 75, 230, 70, 80, 85, 193, 136, 183, 222, 146, 46, 235, 0, 222, 118, 32, 70,
|
||||||
166, 231, 123, 101, 236, 147, 144, 2, 9, 51, 2, 189, 188, 200, 66, 29, 16, 22, 150,
|
85, 39, 92, 233, 211, 169, 159, 207, 145, 13, 206, 125, 3, 45, 51, 64, 167, 179,
|
||||||
45, 220, 15, 161, 180, 214, 244, 104, 41, 77, 171, 246, 243, 56, 47, 63, 103, 216,
|
133, 83, 57, 190, 51, 239, 211, 74, 116, 75, 71, 248, 249, 184, 13, 31, 129, 107,
|
||||||
151, 199, 249, 169, 165, 119, 200, 243, 161, 83, 46, 225, 195, 92, 96, 150, 0, 165,
|
104, 179, 76, 194, 186, 4, 13, 122, 167, 254, 126, 153, 50, 8, 1, 200, 203, 213,
|
||||||
170, 14, 211, 226, 244, 70, 218, 137, 254, 197, 175, 208, 119, 199, 121, 4, 7, 190,
|
230, 217, 97, 105, 50, 208, 126, 180, 113, 81, 152, 238, 123, 157, 232, 19, 164,
|
||||||
118, 55, 197, 208, 41, 109, 161, 34, 33, 210, 58, 99, 81, 97, 57, 156, 57, 144, 83,
|
159, 164, 89, 75, 33, 70, 140, 204, 158, 236, 10, 226, 102, 14, 88, 134, 82, 131,
|
||||||
97, 49, 248, 89, 201, 88, 169, 9, 211, 34, 136, 174, 195, 224, 51, 103, 12, 237,
|
36, 195, 127, 158, 81, 252, 223, 165, 11, 52, 105, 245, 245, 228, 235, 168, 175,
|
||||||
172, 46, 216, 5, 168,
|
52, 175, 76, 157, 120, 208, 99, 135, 210, 81, 114, 230, 181,
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -221,11 +221,11 @@ mod test {
|
||||||
println!("floonet genesis full hash: {}\n", gen_bin.hash().to_hex());
|
println!("floonet genesis full hash: {}\n", gen_bin.hash().to_hex());
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
gen_hash.to_hex(),
|
gen_hash.to_hex(),
|
||||||
"cb272478ee4abbf41a3d8cc8f2f828785cf38bd7f0dcacfdd6db5f8f2d8f6e24"
|
"edc758c1370d43e1d733f70f58cf187c3be8242830429b1676b89fd91ccf2dab"
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
gen_bin.hash().to_hex(),
|
gen_bin.hash().to_hex(),
|
||||||
"5fcc7afebc2dcfb98f982dd4d9ff7878fca45038d22677ef6360745c90505035"
|
"91c638fc019a54e6652bd6bb3d9c5e0c17e889cef34a5c28528e7eb61a884dc4"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -93,6 +93,18 @@ pub enum ChainTypes {
|
||||||
Mainnet,
|
Mainnet,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl ChainTypes {
|
||||||
|
/// Short name representing the chain type ("floo", "main", etc.)
|
||||||
|
pub fn shortname(&self) -> String {
|
||||||
|
match *self {
|
||||||
|
ChainTypes::AutomatedTesting => "auto".to_owned(),
|
||||||
|
ChainTypes::UserTesting => "user".to_owned(),
|
||||||
|
ChainTypes::Floonet => "floo".to_owned(),
|
||||||
|
ChainTypes::Mainnet => "main".to_owned(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Default for ChainTypes {
|
impl Default for ChainTypes {
|
||||||
fn default() -> ChainTypes {
|
fn default() -> ChainTypes {
|
||||||
ChainTypes::Floonet
|
ChainTypes::Floonet
|
||||||
|
@ -152,11 +164,6 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return the type of the pos
|
|
||||||
pub fn pow_type() -> PoWContextTypes {
|
|
||||||
PoWContextTypes::Cuckatoo
|
|
||||||
}
|
|
||||||
|
|
||||||
/// The minimum acceptable edge_bits
|
/// The minimum acceptable edge_bits
|
||||||
pub fn min_edge_bits() -> u8 {
|
pub fn min_edge_bits() -> u8 {
|
||||||
let param_ref = CHAIN_TYPE.read();
|
let param_ref = CHAIN_TYPE.read();
|
||||||
|
@ -256,12 +263,11 @@ pub fn is_user_testing_mode() -> bool {
|
||||||
/// Production defined as a live public network, testnet[n] or mainnet.
|
/// Production defined as a live public network, testnet[n] or mainnet.
|
||||||
pub fn is_production_mode() -> bool {
|
pub fn is_production_mode() -> bool {
|
||||||
let param_ref = CHAIN_TYPE.read();
|
let param_ref = CHAIN_TYPE.read();
|
||||||
ChainTypes::Floonet == *param_ref
|
ChainTypes::Floonet == *param_ref || ChainTypes::Mainnet == *param_ref
|
||||||
|| ChainTypes::Mainnet == *param_ref
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Are we in one of our (many) testnets?
|
/// Are we in floonet?
|
||||||
pub fn is_testnet() -> bool {
|
pub fn is_floonet() -> bool {
|
||||||
let param_ref = CHAIN_TYPE.read();
|
let param_ref = CHAIN_TYPE.read();
|
||||||
ChainTypes::Floonet == *param_ref
|
ChainTypes::Floonet == *param_ref
|
||||||
}
|
}
|
||||||
|
@ -290,6 +296,12 @@ pub fn get_genesis_nonce() -> u64 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Short name representing the current chain type ("floo", "main", etc.)
|
||||||
|
pub fn chain_shortname() -> String {
|
||||||
|
let param_ref = CHAIN_TYPE.read();
|
||||||
|
param_ref.shortname()
|
||||||
|
}
|
||||||
|
|
||||||
/// Converts an iterator of block difficulty data to more a more manageable
|
/// Converts an iterator of block difficulty data to more a more manageable
|
||||||
/// vector and pads if needed (which will) only be needed for the first few
|
/// vector and pads if needed (which will) only be needed for the first few
|
||||||
/// blocks after genesis
|
/// blocks after genesis
|
||||||
|
|
|
@ -234,7 +234,7 @@ pub fn verify_partial_sig(
|
||||||
/// use keychain::{Keychain, ExtKeychain};
|
/// use keychain::{Keychain, ExtKeychain};
|
||||||
///
|
///
|
||||||
/// let secp = Secp256k1::with_caps(ContextFlag::Commit);
|
/// let secp = Secp256k1::with_caps(ContextFlag::Commit);
|
||||||
/// let keychain = ExtKeychain::from_random_seed().unwrap();
|
/// let keychain = ExtKeychain::from_random_seed(false).unwrap();
|
||||||
/// let fees = 10_000;
|
/// let fees = 10_000;
|
||||||
/// let value = reward(fees);
|
/// let value = reward(fees);
|
||||||
/// let key_id = ExtKeychain::derive_key_id(1, 1, 0, 0, 0);
|
/// let key_id = ExtKeychain::derive_key_id(1, 1, 0, 0, 0);
|
||||||
|
@ -266,16 +266,7 @@ where
|
||||||
K: Keychain,
|
K: Keychain,
|
||||||
{
|
{
|
||||||
let skey = k.derive_key(value, key_id)?;
|
let skey = k.derive_key(value, key_id)?;
|
||||||
let sig = aggsig::sign_single(
|
let sig = aggsig::sign_single(secp, &msg, &skey, None, None, None, blind_sum, None)?;
|
||||||
secp,
|
|
||||||
&msg,
|
|
||||||
&skey,
|
|
||||||
None,
|
|
||||||
None,
|
|
||||||
None,
|
|
||||||
blind_sum,
|
|
||||||
None,
|
|
||||||
)?;
|
|
||||||
Ok(sig)
|
Ok(sig)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -308,7 +299,7 @@ where
|
||||||
///
|
///
|
||||||
/// // Create signature
|
/// // Create signature
|
||||||
/// let secp = Secp256k1::with_caps(ContextFlag::Commit);
|
/// let secp = Secp256k1::with_caps(ContextFlag::Commit);
|
||||||
/// let keychain = ExtKeychain::from_random_seed().unwrap();
|
/// let keychain = ExtKeychain::from_random_seed(false).unwrap();
|
||||||
/// let fees = 10_000;
|
/// let fees = 10_000;
|
||||||
/// let value = reward(fees);
|
/// let value = reward(fees);
|
||||||
/// let key_id = ExtKeychain::derive_key_id(1, 1, 0, 0, 0);
|
/// let key_id = ExtKeychain::derive_key_id(1, 1, 0, 0, 0);
|
||||||
|
|
|
@ -54,7 +54,11 @@ where
|
||||||
move |build, (tx, kern, sum)| -> (Transaction, TxKernel, BlindSum) {
|
move |build, (tx, kern, sum)| -> (Transaction, TxKernel, BlindSum) {
|
||||||
let commit = build.keychain.commit(value, &key_id).unwrap();
|
let commit = build.keychain.commit(value, &key_id).unwrap();
|
||||||
let input = Input::new(features, commit);
|
let input = Input::new(features, commit);
|
||||||
(tx.with_input(input), kern, sum.sub_key_id(key_id.to_value_path(value)))
|
(
|
||||||
|
tx.with_input(input),
|
||||||
|
kern,
|
||||||
|
sum.sub_key_id(key_id.to_value_path(value)),
|
||||||
|
)
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -261,7 +265,7 @@ mod test {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn blind_simple_tx() {
|
fn blind_simple_tx() {
|
||||||
let keychain = ExtKeychain::from_random_seed().unwrap();
|
let keychain = ExtKeychain::from_random_seed(false).unwrap();
|
||||||
let key_id1 = ExtKeychainPath::new(1, 1, 0, 0, 0).to_identifier();
|
let key_id1 = ExtKeychainPath::new(1, 1, 0, 0, 0).to_identifier();
|
||||||
let key_id2 = ExtKeychainPath::new(1, 2, 0, 0, 0).to_identifier();
|
let key_id2 = ExtKeychainPath::new(1, 2, 0, 0, 0).to_identifier();
|
||||||
let key_id3 = ExtKeychainPath::new(1, 3, 0, 0, 0).to_identifier();
|
let key_id3 = ExtKeychainPath::new(1, 3, 0, 0, 0).to_identifier();
|
||||||
|
@ -284,7 +288,7 @@ mod test {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn blind_simple_tx_with_offset() {
|
fn blind_simple_tx_with_offset() {
|
||||||
let keychain = ExtKeychain::from_random_seed().unwrap();
|
let keychain = ExtKeychain::from_random_seed(false).unwrap();
|
||||||
let key_id1 = ExtKeychainPath::new(1, 1, 0, 0, 0).to_identifier();
|
let key_id1 = ExtKeychainPath::new(1, 1, 0, 0, 0).to_identifier();
|
||||||
let key_id2 = ExtKeychainPath::new(1, 2, 0, 0, 0).to_identifier();
|
let key_id2 = ExtKeychainPath::new(1, 2, 0, 0, 0).to_identifier();
|
||||||
let key_id3 = ExtKeychainPath::new(1, 3, 0, 0, 0).to_identifier();
|
let key_id3 = ExtKeychainPath::new(1, 3, 0, 0, 0).to_identifier();
|
||||||
|
@ -307,7 +311,7 @@ mod test {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn blind_simpler_tx() {
|
fn blind_simpler_tx() {
|
||||||
let keychain = ExtKeychain::from_random_seed().unwrap();
|
let keychain = ExtKeychain::from_random_seed(false).unwrap();
|
||||||
let key_id1 = ExtKeychainPath::new(1, 1, 0, 0, 0).to_identifier();
|
let key_id1 = ExtKeychainPath::new(1, 1, 0, 0, 0).to_identifier();
|
||||||
let key_id2 = ExtKeychainPath::new(1, 2, 0, 0, 0).to_identifier();
|
let key_id2 = ExtKeychainPath::new(1, 2, 0, 0, 0).to_identifier();
|
||||||
|
|
||||||
|
|
|
@ -260,7 +260,7 @@ impl Slate {
|
||||||
if let Some(m) = message.clone() {
|
if let Some(m) = message.clone() {
|
||||||
let hashed = blake2b(secp::constants::MESSAGE_SIZE, &[], &m.as_bytes()[..]);
|
let hashed = blake2b(secp::constants::MESSAGE_SIZE, &[], &m.as_bytes()[..]);
|
||||||
let m = secp::Message::from_slice(&hashed.as_bytes())?;
|
let m = secp::Message::from_slice(&hashed.as_bytes())?;
|
||||||
let res = aggsig::sign_single(&keychain.secp(), &m, &sec_key, None)?;
|
let res = aggsig::sign_single(&keychain.secp(), &m, &sec_key, Some(&pub_key))?;
|
||||||
Some(res)
|
Some(res)
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
|
@ -360,7 +360,7 @@ impl Slate {
|
||||||
&m,
|
&m,
|
||||||
None,
|
None,
|
||||||
&p.public_blind_excess,
|
&p.public_blind_excess,
|
||||||
None,
|
Some(&p.public_blind_excess),
|
||||||
false,
|
false,
|
||||||
) {
|
) {
|
||||||
error!("verify_messages - participant message doesn't match signature. Message: \"{}\"",
|
error!("verify_messages - participant message doesn't match signature. Message: \"{}\"",
|
||||||
|
|
|
@ -136,11 +136,12 @@ mod test {
|
||||||
/// We'll be generating genesis blocks differently
|
/// We'll be generating genesis blocks differently
|
||||||
#[test]
|
#[test]
|
||||||
fn genesis_pow() {
|
fn genesis_pow() {
|
||||||
global::set_mining_mode(ChainTypes::AutomatedTesting);
|
global::set_mining_mode(ChainTypes::UserTesting);
|
||||||
|
|
||||||
let mut b = genesis::genesis_dev();
|
let mut b = genesis::genesis_dev();
|
||||||
b.header.pow.nonce = 485;
|
b.header.pow.nonce = 28106;
|
||||||
b.header.pow.proof.edge_bits = global::min_edge_bits();
|
b.header.pow.proof.edge_bits = global::min_edge_bits();
|
||||||
|
println!("proof {}", global::proofsize());
|
||||||
pow_size(
|
pow_size(
|
||||||
&mut b.header,
|
&mut b.header,
|
||||||
Difficulty::min(),
|
Difficulty::min(),
|
||||||
|
@ -148,8 +149,13 @@ mod test {
|
||||||
global::min_edge_bits(),
|
global::min_edge_bits(),
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
println!("nonce {}", b.header.pow.nonce);
|
||||||
assert_ne!(b.header.pow.nonce, 310);
|
assert_ne!(b.header.pow.nonce, 310);
|
||||||
assert!(b.header.pow.to_difficulty(0) >= Difficulty::min());
|
assert!(b.header.pow.to_difficulty(0) >= Difficulty::min());
|
||||||
assert!(verify_size(&b.header).is_ok());
|
let start = ::std::time::Instant::now();
|
||||||
|
for n in 0..100000 {
|
||||||
|
assert!(verify_size(&b.header).is_ok());
|
||||||
|
}
|
||||||
|
println!("==> {}", start.elapsed().as_secs());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@ fn verifier_cache() -> Arc<RwLock<dyn VerifierCache>> {
|
||||||
// TODO: make this fast enough or add similar but faster test?
|
// TODO: make this fast enough or add similar but faster test?
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
fn too_large_block() {
|
fn too_large_block() {
|
||||||
let keychain = ExtKeychain::from_random_seed().unwrap();
|
let keychain = ExtKeychain::from_random_seed(false).unwrap();
|
||||||
let max_out = MAX_BLOCK_WEIGHT / BLOCK_OUTPUT_WEIGHT;
|
let max_out = MAX_BLOCK_WEIGHT / BLOCK_OUTPUT_WEIGHT;
|
||||||
|
|
||||||
let mut pks = vec![];
|
let mut pks = vec![];
|
||||||
|
@ -83,7 +83,7 @@ fn very_empty_block() {
|
||||||
#[test]
|
#[test]
|
||||||
// builds a block with a tx spending another and check that cut_through occurred
|
// builds a block with a tx spending another and check that cut_through occurred
|
||||||
fn block_with_cut_through() {
|
fn block_with_cut_through() {
|
||||||
let keychain = ExtKeychain::from_random_seed().unwrap();
|
let keychain = ExtKeychain::from_random_seed(false).unwrap();
|
||||||
let key_id1 = ExtKeychain::derive_key_id(1, 1, 0, 0, 0);
|
let key_id1 = ExtKeychain::derive_key_id(1, 1, 0, 0, 0);
|
||||||
let key_id2 = ExtKeychain::derive_key_id(1, 2, 0, 0, 0);
|
let key_id2 = ExtKeychain::derive_key_id(1, 2, 0, 0, 0);
|
||||||
let key_id3 = ExtKeychain::derive_key_id(1, 3, 0, 0, 0);
|
let key_id3 = ExtKeychain::derive_key_id(1, 3, 0, 0, 0);
|
||||||
|
@ -119,7 +119,7 @@ fn block_with_cut_through() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn empty_block_with_coinbase_is_valid() {
|
fn empty_block_with_coinbase_is_valid() {
|
||||||
let keychain = ExtKeychain::from_random_seed().unwrap();
|
let keychain = ExtKeychain::from_random_seed(false).unwrap();
|
||||||
let prev = BlockHeader::default();
|
let prev = BlockHeader::default();
|
||||||
let key_id = ExtKeychain::derive_key_id(1, 1, 0, 0, 0);
|
let key_id = ExtKeychain::derive_key_id(1, 1, 0, 0, 0);
|
||||||
let b = new_block(vec![], &keychain, &prev, &key_id);
|
let b = new_block(vec![], &keychain, &prev, &key_id);
|
||||||
|
@ -156,7 +156,7 @@ fn empty_block_with_coinbase_is_valid() {
|
||||||
// invalidates the block and specifically it causes verify_coinbase to fail
|
// invalidates the block and specifically it causes verify_coinbase to fail
|
||||||
// additionally verifying the merkle_inputs_outputs also fails
|
// additionally verifying the merkle_inputs_outputs also fails
|
||||||
fn remove_coinbase_output_flag() {
|
fn remove_coinbase_output_flag() {
|
||||||
let keychain = ExtKeychain::from_random_seed().unwrap();
|
let keychain = ExtKeychain::from_random_seed(false).unwrap();
|
||||||
let prev = BlockHeader::default();
|
let prev = BlockHeader::default();
|
||||||
let key_id = ExtKeychain::derive_key_id(1, 1, 0, 0, 0);
|
let key_id = ExtKeychain::derive_key_id(1, 1, 0, 0, 0);
|
||||||
let mut b = new_block(vec![], &keychain, &prev, &key_id);
|
let mut b = new_block(vec![], &keychain, &prev, &key_id);
|
||||||
|
@ -178,7 +178,7 @@ fn remove_coinbase_output_flag() {
|
||||||
// test that flipping the COINBASE flag on the kernel features
|
// test that flipping the COINBASE flag on the kernel features
|
||||||
// invalidates the block and specifically it causes verify_coinbase to fail
|
// invalidates the block and specifically it causes verify_coinbase to fail
|
||||||
fn remove_coinbase_kernel_flag() {
|
fn remove_coinbase_kernel_flag() {
|
||||||
let keychain = ExtKeychain::from_random_seed().unwrap();
|
let keychain = ExtKeychain::from_random_seed(false).unwrap();
|
||||||
let prev = BlockHeader::default();
|
let prev = BlockHeader::default();
|
||||||
let key_id = ExtKeychain::derive_key_id(1, 1, 0, 0, 0);
|
let key_id = ExtKeychain::derive_key_id(1, 1, 0, 0, 0);
|
||||||
let mut b = new_block(vec![], &keychain, &prev, &key_id);
|
let mut b = new_block(vec![], &keychain, &prev, &key_id);
|
||||||
|
@ -202,7 +202,7 @@ fn remove_coinbase_kernel_flag() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn serialize_deserialize_block_header() {
|
fn serialize_deserialize_block_header() {
|
||||||
let keychain = ExtKeychain::from_random_seed().unwrap();
|
let keychain = ExtKeychain::from_random_seed(false).unwrap();
|
||||||
let prev = BlockHeader::default();
|
let prev = BlockHeader::default();
|
||||||
let key_id = ExtKeychain::derive_key_id(1, 1, 0, 0, 0);
|
let key_id = ExtKeychain::derive_key_id(1, 1, 0, 0, 0);
|
||||||
let b = new_block(vec![], &keychain, &prev, &key_id);
|
let b = new_block(vec![], &keychain, &prev, &key_id);
|
||||||
|
@ -219,7 +219,7 @@ fn serialize_deserialize_block_header() {
|
||||||
#[test]
|
#[test]
|
||||||
fn serialize_deserialize_block() {
|
fn serialize_deserialize_block() {
|
||||||
let tx1 = tx1i2o();
|
let tx1 = tx1i2o();
|
||||||
let keychain = ExtKeychain::from_random_seed().unwrap();
|
let keychain = ExtKeychain::from_random_seed(false).unwrap();
|
||||||
let prev = BlockHeader::default();
|
let prev = BlockHeader::default();
|
||||||
let key_id = ExtKeychain::derive_key_id(1, 1, 0, 0, 0);
|
let key_id = ExtKeychain::derive_key_id(1, 1, 0, 0, 0);
|
||||||
let b = new_block(vec![&tx1], &keychain, &prev, &key_id);
|
let b = new_block(vec![&tx1], &keychain, &prev, &key_id);
|
||||||
|
@ -237,7 +237,7 @@ fn serialize_deserialize_block() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn empty_block_serialized_size() {
|
fn empty_block_serialized_size() {
|
||||||
let keychain = ExtKeychain::from_random_seed().unwrap();
|
let keychain = ExtKeychain::from_random_seed(false).unwrap();
|
||||||
let prev = BlockHeader::default();
|
let prev = BlockHeader::default();
|
||||||
let key_id = ExtKeychain::derive_key_id(1, 1, 0, 0, 0);
|
let key_id = ExtKeychain::derive_key_id(1, 1, 0, 0, 0);
|
||||||
let b = new_block(vec![], &keychain, &prev, &key_id);
|
let b = new_block(vec![], &keychain, &prev, &key_id);
|
||||||
|
@ -249,7 +249,7 @@ fn empty_block_serialized_size() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn block_single_tx_serialized_size() {
|
fn block_single_tx_serialized_size() {
|
||||||
let keychain = ExtKeychain::from_random_seed().unwrap();
|
let keychain = ExtKeychain::from_random_seed(false).unwrap();
|
||||||
let tx1 = tx1i2o();
|
let tx1 = tx1i2o();
|
||||||
let prev = BlockHeader::default();
|
let prev = BlockHeader::default();
|
||||||
let key_id = ExtKeychain::derive_key_id(1, 1, 0, 0, 0);
|
let key_id = ExtKeychain::derive_key_id(1, 1, 0, 0, 0);
|
||||||
|
@ -262,7 +262,7 @@ fn block_single_tx_serialized_size() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn empty_compact_block_serialized_size() {
|
fn empty_compact_block_serialized_size() {
|
||||||
let keychain = ExtKeychain::from_random_seed().unwrap();
|
let keychain = ExtKeychain::from_random_seed(false).unwrap();
|
||||||
let prev = BlockHeader::default();
|
let prev = BlockHeader::default();
|
||||||
let key_id = ExtKeychain::derive_key_id(1, 1, 0, 0, 0);
|
let key_id = ExtKeychain::derive_key_id(1, 1, 0, 0, 0);
|
||||||
let b = new_block(vec![], &keychain, &prev, &key_id);
|
let b = new_block(vec![], &keychain, &prev, &key_id);
|
||||||
|
@ -275,7 +275,7 @@ fn empty_compact_block_serialized_size() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn compact_block_single_tx_serialized_size() {
|
fn compact_block_single_tx_serialized_size() {
|
||||||
let keychain = ExtKeychain::from_random_seed().unwrap();
|
let keychain = ExtKeychain::from_random_seed(false).unwrap();
|
||||||
let tx1 = tx1i2o();
|
let tx1 = tx1i2o();
|
||||||
let prev = BlockHeader::default();
|
let prev = BlockHeader::default();
|
||||||
let key_id = ExtKeychain::derive_key_id(1, 1, 0, 0, 0);
|
let key_id = ExtKeychain::derive_key_id(1, 1, 0, 0, 0);
|
||||||
|
@ -289,7 +289,7 @@ fn compact_block_single_tx_serialized_size() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn block_10_tx_serialized_size() {
|
fn block_10_tx_serialized_size() {
|
||||||
let keychain = ExtKeychain::from_random_seed().unwrap();
|
let keychain = ExtKeychain::from_random_seed(false).unwrap();
|
||||||
global::set_mining_mode(global::ChainTypes::Mainnet);
|
global::set_mining_mode(global::ChainTypes::Mainnet);
|
||||||
|
|
||||||
let mut txs = vec![];
|
let mut txs = vec![];
|
||||||
|
@ -308,7 +308,7 @@ fn block_10_tx_serialized_size() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn compact_block_10_tx_serialized_size() {
|
fn compact_block_10_tx_serialized_size() {
|
||||||
let keychain = ExtKeychain::from_random_seed().unwrap();
|
let keychain = ExtKeychain::from_random_seed(false).unwrap();
|
||||||
|
|
||||||
let mut txs = vec![];
|
let mut txs = vec![];
|
||||||
for _ in 0..10 {
|
for _ in 0..10 {
|
||||||
|
@ -327,7 +327,7 @@ fn compact_block_10_tx_serialized_size() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn compact_block_hash_with_nonce() {
|
fn compact_block_hash_with_nonce() {
|
||||||
let keychain = ExtKeychain::from_random_seed().unwrap();
|
let keychain = ExtKeychain::from_random_seed(false).unwrap();
|
||||||
let tx = tx1i2o();
|
let tx = tx1i2o();
|
||||||
let prev = BlockHeader::default();
|
let prev = BlockHeader::default();
|
||||||
let key_id = ExtKeychain::derive_key_id(1, 1, 0, 0, 0);
|
let key_id = ExtKeychain::derive_key_id(1, 1, 0, 0, 0);
|
||||||
|
@ -357,7 +357,7 @@ fn compact_block_hash_with_nonce() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn convert_block_to_compact_block() {
|
fn convert_block_to_compact_block() {
|
||||||
let keychain = ExtKeychain::from_random_seed().unwrap();
|
let keychain = ExtKeychain::from_random_seed(false).unwrap();
|
||||||
let tx1 = tx1i2o();
|
let tx1 = tx1i2o();
|
||||||
let prev = BlockHeader::default();
|
let prev = BlockHeader::default();
|
||||||
let key_id = ExtKeychain::derive_key_id(1, 1, 0, 0, 0);
|
let key_id = ExtKeychain::derive_key_id(1, 1, 0, 0, 0);
|
||||||
|
@ -380,7 +380,7 @@ fn convert_block_to_compact_block() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn hydrate_empty_compact_block() {
|
fn hydrate_empty_compact_block() {
|
||||||
let keychain = ExtKeychain::from_random_seed().unwrap();
|
let keychain = ExtKeychain::from_random_seed(false).unwrap();
|
||||||
let prev = BlockHeader::default();
|
let prev = BlockHeader::default();
|
||||||
let key_id = ExtKeychain::derive_key_id(1, 1, 0, 0, 0);
|
let key_id = ExtKeychain::derive_key_id(1, 1, 0, 0, 0);
|
||||||
let b = new_block(vec![], &keychain, &prev, &key_id);
|
let b = new_block(vec![], &keychain, &prev, &key_id);
|
||||||
|
@ -393,7 +393,7 @@ fn hydrate_empty_compact_block() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn serialize_deserialize_compact_block() {
|
fn serialize_deserialize_compact_block() {
|
||||||
let keychain = ExtKeychain::from_random_seed().unwrap();
|
let keychain = ExtKeychain::from_random_seed(false).unwrap();
|
||||||
let tx1 = tx1i2o();
|
let tx1 = tx1i2o();
|
||||||
let prev = BlockHeader::default();
|
let prev = BlockHeader::default();
|
||||||
let key_id = ExtKeychain::derive_key_id(1, 1, 0, 0, 0);
|
let key_id = ExtKeychain::derive_key_id(1, 1, 0, 0, 0);
|
||||||
|
|
|
@ -29,7 +29,7 @@ use grin_keychain as keychain;
|
||||||
|
|
||||||
// utility producing a transaction with 2 inputs and a single outputs
|
// utility producing a transaction with 2 inputs and a single outputs
|
||||||
pub fn tx2i1o() -> Transaction {
|
pub fn tx2i1o() -> Transaction {
|
||||||
let keychain = keychain::ExtKeychain::from_random_seed().unwrap();
|
let keychain = keychain::ExtKeychain::from_random_seed(false).unwrap();
|
||||||
let key_id1 = keychain::ExtKeychain::derive_key_id(1, 1, 0, 0, 0);
|
let key_id1 = keychain::ExtKeychain::derive_key_id(1, 1, 0, 0, 0);
|
||||||
let key_id2 = keychain::ExtKeychain::derive_key_id(1, 2, 0, 0, 0);
|
let key_id2 = keychain::ExtKeychain::derive_key_id(1, 2, 0, 0, 0);
|
||||||
let key_id3 = keychain::ExtKeychain::derive_key_id(1, 3, 0, 0, 0);
|
let key_id3 = keychain::ExtKeychain::derive_key_id(1, 3, 0, 0, 0);
|
||||||
|
@ -48,7 +48,7 @@ pub fn tx2i1o() -> Transaction {
|
||||||
|
|
||||||
// utility producing a transaction with a single input and output
|
// utility producing a transaction with a single input and output
|
||||||
pub fn tx1i1o() -> Transaction {
|
pub fn tx1i1o() -> Transaction {
|
||||||
let keychain = keychain::ExtKeychain::from_random_seed().unwrap();
|
let keychain = keychain::ExtKeychain::from_random_seed(false).unwrap();
|
||||||
let key_id1 = keychain::ExtKeychain::derive_key_id(1, 1, 0, 0, 0);
|
let key_id1 = keychain::ExtKeychain::derive_key_id(1, 1, 0, 0, 0);
|
||||||
let key_id2 = keychain::ExtKeychain::derive_key_id(1, 2, 0, 0, 0);
|
let key_id2 = keychain::ExtKeychain::derive_key_id(1, 2, 0, 0, 0);
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ pub fn tx1i1o() -> Transaction {
|
||||||
// and two outputs (one change output)
|
// and two outputs (one change output)
|
||||||
// Note: this tx has an "offset" kernel
|
// Note: this tx has an "offset" kernel
|
||||||
pub fn tx1i2o() -> Transaction {
|
pub fn tx1i2o() -> Transaction {
|
||||||
let keychain = keychain::ExtKeychain::from_random_seed().unwrap();
|
let keychain = keychain::ExtKeychain::from_random_seed(false).unwrap();
|
||||||
let key_id1 = keychain::ExtKeychain::derive_key_id(1, 1, 0, 0, 0);
|
let key_id1 = keychain::ExtKeychain::derive_key_id(1, 1, 0, 0, 0);
|
||||||
let key_id2 = keychain::ExtKeychain::derive_key_id(1, 2, 0, 0, 0);
|
let key_id2 = keychain::ExtKeychain::derive_key_id(1, 2, 0, 0, 0);
|
||||||
let key_id3 = keychain::ExtKeychain::derive_key_id(1, 3, 0, 0, 0);
|
let key_id3 = keychain::ExtKeychain::derive_key_id(1, 3, 0, 0, 0);
|
||||||
|
|
|
@ -454,7 +454,7 @@ fn test_secondary_pow_ratio() {
|
||||||
// Tests for mainnet chain type.
|
// Tests for mainnet chain type.
|
||||||
{
|
{
|
||||||
global::set_mining_mode(global::ChainTypes::Mainnet);
|
global::set_mining_mode(global::ChainTypes::Mainnet);
|
||||||
assert_eq!(global::is_testnet(), false);
|
assert_eq!(global::is_floonet(), false);
|
||||||
|
|
||||||
assert_eq!(secondary_pow_ratio(1), 90);
|
assert_eq!(secondary_pow_ratio(1), 90);
|
||||||
assert_eq!(secondary_pow_ratio(89), 90);
|
assert_eq!(secondary_pow_ratio(89), 90);
|
||||||
|
@ -496,7 +496,7 @@ fn test_secondary_pow_ratio() {
|
||||||
// Tests for testnet4 chain type (covers pre and post hardfork).
|
// Tests for testnet4 chain type (covers pre and post hardfork).
|
||||||
{
|
{
|
||||||
global::set_mining_mode(global::ChainTypes::Floonet);
|
global::set_mining_mode(global::ChainTypes::Floonet);
|
||||||
assert_eq!(global::is_testnet(), true);
|
assert_eq!(global::is_floonet(), true);
|
||||||
|
|
||||||
assert_eq!(secondary_pow_ratio(1), 90);
|
assert_eq!(secondary_pow_ratio(1), 90);
|
||||||
assert_eq!(secondary_pow_ratio(89), 90);
|
assert_eq!(secondary_pow_ratio(89), 90);
|
||||||
|
@ -544,7 +544,7 @@ fn test_secondary_pow_scale() {
|
||||||
// mainnet testing
|
// mainnet testing
|
||||||
{
|
{
|
||||||
global::set_mining_mode(global::ChainTypes::Mainnet);
|
global::set_mining_mode(global::ChainTypes::Mainnet);
|
||||||
assert_eq!(global::is_mainnet(), true);
|
assert_eq!(global::is_floonet(), false);
|
||||||
|
|
||||||
// all primary, factor should increase so it becomes easier to find a high
|
// all primary, factor should increase so it becomes easier to find a high
|
||||||
// difficulty block
|
// difficulty block
|
||||||
|
|
|
@ -75,7 +75,7 @@ fn tx_double_ser_deser() {
|
||||||
#[test]
|
#[test]
|
||||||
#[should_panic(expected = "Keychain Error")]
|
#[should_panic(expected = "Keychain Error")]
|
||||||
fn test_zero_commit_fails() {
|
fn test_zero_commit_fails() {
|
||||||
let mut keychain = ExtKeychain::from_random_seed().unwrap();
|
let mut keychain = ExtKeychain::from_random_seed(false).unwrap();
|
||||||
keychain.set_use_switch_commits(false);
|
keychain.set_use_switch_commits(false);
|
||||||
let key_id1 = ExtKeychain::derive_key_id(1, 1, 0, 0, 0);
|
let key_id1 = ExtKeychain::derive_key_id(1, 1, 0, 0, 0);
|
||||||
|
|
||||||
|
@ -97,7 +97,7 @@ fn verifier_cache() -> Arc<RwLock<dyn VerifierCache>> {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn build_tx_kernel() {
|
fn build_tx_kernel() {
|
||||||
let keychain = ExtKeychain::from_random_seed().unwrap();
|
let keychain = ExtKeychain::from_random_seed(false).unwrap();
|
||||||
let key_id1 = ExtKeychain::derive_key_id(1, 1, 0, 0, 0);
|
let key_id1 = ExtKeychain::derive_key_id(1, 1, 0, 0, 0);
|
||||||
let key_id2 = ExtKeychain::derive_key_id(1, 2, 0, 0, 0);
|
let key_id2 = ExtKeychain::derive_key_id(1, 2, 0, 0, 0);
|
||||||
let key_id3 = ExtKeychain::derive_key_id(1, 3, 0, 0, 0);
|
let key_id3 = ExtKeychain::derive_key_id(1, 3, 0, 0, 0);
|
||||||
|
@ -322,7 +322,7 @@ fn basic_transaction_deaggregation() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn hash_output() {
|
fn hash_output() {
|
||||||
let keychain = ExtKeychain::from_random_seed().unwrap();
|
let keychain = ExtKeychain::from_random_seed(false).unwrap();
|
||||||
let key_id1 = ExtKeychain::derive_key_id(1, 1, 0, 0, 0);
|
let key_id1 = ExtKeychain::derive_key_id(1, 1, 0, 0, 0);
|
||||||
let key_id2 = ExtKeychain::derive_key_id(1, 2, 0, 0, 0);
|
let key_id2 = ExtKeychain::derive_key_id(1, 2, 0, 0, 0);
|
||||||
let key_id3 = ExtKeychain::derive_key_id(1, 3, 0, 0, 0);
|
let key_id3 = ExtKeychain::derive_key_id(1, 3, 0, 0, 0);
|
||||||
|
@ -377,7 +377,7 @@ fn tx_hash_diff() {
|
||||||
/// 2 inputs, 2 outputs transaction.
|
/// 2 inputs, 2 outputs transaction.
|
||||||
#[test]
|
#[test]
|
||||||
fn tx_build_exchange() {
|
fn tx_build_exchange() {
|
||||||
let keychain = ExtKeychain::from_random_seed().unwrap();
|
let keychain = ExtKeychain::from_random_seed(false).unwrap();
|
||||||
let key_id1 = ExtKeychain::derive_key_id(1, 1, 0, 0, 0);
|
let key_id1 = ExtKeychain::derive_key_id(1, 1, 0, 0, 0);
|
||||||
let key_id2 = ExtKeychain::derive_key_id(1, 2, 0, 0, 0);
|
let key_id2 = ExtKeychain::derive_key_id(1, 2, 0, 0, 0);
|
||||||
let key_id3 = ExtKeychain::derive_key_id(1, 3, 0, 0, 0);
|
let key_id3 = ExtKeychain::derive_key_id(1, 3, 0, 0, 0);
|
||||||
|
@ -415,7 +415,7 @@ fn tx_build_exchange() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn reward_empty_block() {
|
fn reward_empty_block() {
|
||||||
let keychain = keychain::ExtKeychain::from_random_seed().unwrap();
|
let keychain = keychain::ExtKeychain::from_random_seed(false).unwrap();
|
||||||
let key_id = ExtKeychain::derive_key_id(1, 1, 0, 0, 0);
|
let key_id = ExtKeychain::derive_key_id(1, 1, 0, 0, 0);
|
||||||
|
|
||||||
let previous_header = BlockHeader::default();
|
let previous_header = BlockHeader::default();
|
||||||
|
@ -430,7 +430,7 @@ fn reward_empty_block() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn reward_with_tx_block() {
|
fn reward_with_tx_block() {
|
||||||
let keychain = keychain::ExtKeychain::from_random_seed().unwrap();
|
let keychain = keychain::ExtKeychain::from_random_seed(false).unwrap();
|
||||||
let key_id = ExtKeychain::derive_key_id(1, 1, 0, 0, 0);
|
let key_id = ExtKeychain::derive_key_id(1, 1, 0, 0, 0);
|
||||||
|
|
||||||
let vc = verifier_cache();
|
let vc = verifier_cache();
|
||||||
|
@ -450,7 +450,7 @@ fn reward_with_tx_block() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn simple_block() {
|
fn simple_block() {
|
||||||
let keychain = keychain::ExtKeychain::from_random_seed().unwrap();
|
let keychain = keychain::ExtKeychain::from_random_seed(false).unwrap();
|
||||||
let key_id = ExtKeychain::derive_key_id(1, 1, 0, 0, 0);
|
let key_id = ExtKeychain::derive_key_id(1, 1, 0, 0, 0);
|
||||||
|
|
||||||
let vc = verifier_cache();
|
let vc = verifier_cache();
|
||||||
|
@ -471,7 +471,7 @@ fn simple_block() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_block_with_timelocked_tx() {
|
fn test_block_with_timelocked_tx() {
|
||||||
let keychain = keychain::ExtKeychain::from_random_seed().unwrap();
|
let keychain = keychain::ExtKeychain::from_random_seed(false).unwrap();
|
||||||
|
|
||||||
let key_id1 = ExtKeychain::derive_key_id(1, 1, 0, 0, 0);
|
let key_id1 = ExtKeychain::derive_key_id(1, 1, 0, 0, 0);
|
||||||
let key_id2 = ExtKeychain::derive_key_id(1, 2, 0, 0, 0);
|
let key_id2 = ExtKeychain::derive_key_id(1, 2, 0, 0, 0);
|
||||||
|
|
|
@ -25,7 +25,7 @@ use grin_keychain as keychain;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_output_ser_deser() {
|
fn test_output_ser_deser() {
|
||||||
let keychain = ExtKeychain::from_random_seed().unwrap();
|
let keychain = ExtKeychain::from_random_seed(false).unwrap();
|
||||||
let key_id = ExtKeychain::derive_key_id(1, 1, 0, 0, 0);
|
let key_id = ExtKeychain::derive_key_id(1, 1, 0, 0, 0);
|
||||||
let commit = keychain.commit(5, &key_id).unwrap();
|
let commit = keychain.commit(5, &key_id).unwrap();
|
||||||
let proof = proof::create(&keychain, 5, &key_id, commit, None).unwrap();
|
let proof = proof::create(&keychain, 5, &key_id, commit, None).unwrap();
|
||||||
|
|
|
@ -32,7 +32,7 @@ fn verifier_cache() -> Arc<RwLock<dyn VerifierCache>> {
|
||||||
fn test_verifier_cache_rangeproofs() {
|
fn test_verifier_cache_rangeproofs() {
|
||||||
let cache = verifier_cache();
|
let cache = verifier_cache();
|
||||||
|
|
||||||
let keychain = ExtKeychain::from_random_seed().unwrap();
|
let keychain = ExtKeychain::from_random_seed(false).unwrap();
|
||||||
let key_id = ExtKeychain::derive_key_id(1, 1, 0, 0, 0);
|
let key_id = ExtKeychain::derive_key_id(1, 1, 0, 0, 0);
|
||||||
let commit = keychain.commit(5, &key_id).unwrap();
|
let commit = keychain.commit(5, &key_id).unwrap();
|
||||||
let proof = proof::create(&keychain, 5, &key_id, commit, None).unwrap();
|
let proof = proof::create(&keychain, 5, &key_id, commit, None).unwrap();
|
||||||
|
|
|
@ -15,12 +15,12 @@ path = "src/bin/gen_gen.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
chrono = "0.4.4"
|
chrono = "0.4.4"
|
||||||
cuckoo_miner = "0.4.2"
|
cuckoo_miner = "0.5.0"
|
||||||
curl = "0.4.19"
|
curl = "0.4.19"
|
||||||
grin_core = { path = "../../core" }
|
grin_core = { path = "../../core" }
|
||||||
grin_chain = { path = "../../chain" }
|
grin_chain = { path = "../../chain" }
|
||||||
grin_keychain = { path = "../../keychain" }
|
grin_keychain = { path = "../../keychain" }
|
||||||
grin_miner_plugin = "0.4.2"
|
grin_miner_plugin = "0.5.0"
|
||||||
grin_store = { path = "../../store" }
|
grin_store = { path = "../../store" }
|
||||||
grin_util = { path = "../../util" }
|
grin_util = { path = "../../util" }
|
||||||
grin_wallet = { path = "../../wallet" }
|
grin_wallet = { path = "../../wallet" }
|
||||||
|
|
|
@ -85,21 +85,21 @@ fn main() {
|
||||||
&rpassword::prompt_password_stdout("Password: ").unwrap(),
|
&rpassword::prompt_password_stdout("Password: ").unwrap(),
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let keychain: ExtKeychain = seed.derive_keychain().unwrap();
|
let keychain: ExtKeychain = seed.derive_keychain(false).unwrap();
|
||||||
let key_id = ExtKeychain::derive_key_id(2, 1, 0, 0, 0);
|
let key_id = ExtKeychain::derive_key_id(3, 1, 0, 0, 0);
|
||||||
let reward = core::libtx::reward::output(&keychain, &key_id, 0).unwrap();
|
let reward = core::libtx::reward::output(&keychain, &key_id, 0).unwrap();
|
||||||
gen = gen.with_reward(reward.0, reward.1);
|
gen = gen.with_reward(reward.0, reward.1);
|
||||||
|
|
||||||
{
|
{
|
||||||
// setup a tmp chain to set block header roots
|
// setup a tmp chain to set block header roots
|
||||||
core::global::set_mining_mode(core::global::ChainTypes::AutomatedTesting);
|
core::global::set_mining_mode(core::global::ChainTypes::UserTesting);
|
||||||
let tmp_chain = setup_chain(".grin.tmp", core::pow::mine_genesis_block().unwrap());
|
let tmp_chain = setup_chain(".grin.tmp", core::pow::mine_genesis_block().unwrap());
|
||||||
tmp_chain.set_txhashset_roots(&mut gen).unwrap();
|
tmp_chain.set_txhashset_roots(&mut gen).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
// sets the timestamp and prev_root from the bitcoin block (needs to be
|
// sets the timestamp and prev_root from the bitcoin block (needs to be
|
||||||
// after set_txhashset roots to not get overwritten)
|
// after set_txhashset roots to not get overwritten)
|
||||||
gen.header.timestamp = Utc::now() + Duration::minutes(30);
|
gen.header.timestamp = Utc::now() + Duration::minutes(45);
|
||||||
gen.header.prev_root = core::core::hash::Hash::from_hex(&h1).unwrap();
|
gen.header.prev_root = core::core::hash::Hash::from_hex(&h1).unwrap();
|
||||||
|
|
||||||
// mine a Cuckaroo29 block
|
// mine a Cuckaroo29 block
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "grin_keychain"
|
name = "grin_keychain"
|
||||||
version = "0.4.2"
|
version = "0.5.0"
|
||||||
authors = ["Grin Developers <mimblewimble@lists.launchpad.net>"]
|
authors = ["Grin Developers <mimblewimble@lists.launchpad.net>"]
|
||||||
description = "Chain implementation for grin, a simple, private and scalable cryptocurrency implementation based on the MimbleWimble chain format."
|
description = "Chain implementation for grin, a simple, private and scalable cryptocurrency implementation based on the MimbleWimble chain format."
|
||||||
license = "Apache-2.0"
|
license = "Apache-2.0"
|
||||||
|
@ -27,4 +27,4 @@ sha2 = "0.7"
|
||||||
pbkdf2 = "0.2"
|
pbkdf2 = "0.2"
|
||||||
|
|
||||||
|
|
||||||
grin_util = { path = "../util", version = "0.4.2" }
|
grin_util = { path = "../util", version = "0.5.0" }
|
||||||
|
|
|
@ -78,8 +78,8 @@ impl Default for Fingerprint {
|
||||||
/// not what the actual implementation is
|
/// not what the actual implementation is
|
||||||
|
|
||||||
pub trait BIP32Hasher {
|
pub trait BIP32Hasher {
|
||||||
fn network_priv() -> [u8; 4];
|
fn network_priv(&self) -> [u8; 4];
|
||||||
fn network_pub() -> [u8; 4];
|
fn network_pub(&self) -> [u8; 4];
|
||||||
fn master_seed() -> [u8; 12];
|
fn master_seed() -> [u8; 12];
|
||||||
fn init_sha512(&mut self, seed: &[u8]);
|
fn init_sha512(&mut self, seed: &[u8]);
|
||||||
fn append_sha512(&mut self, value: &[u8]);
|
fn append_sha512(&mut self, value: &[u8]);
|
||||||
|
@ -89,27 +89,34 @@ pub trait BIP32Hasher {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Implementation of the above that uses the standard BIP32 Hash algorithms
|
/// Implementation of the above that uses the standard BIP32 Hash algorithms
|
||||||
|
#[derive(Clone, Debug)]
|
||||||
pub struct BIP32GrinHasher {
|
pub struct BIP32GrinHasher {
|
||||||
|
is_floo: bool,
|
||||||
hmac_sha512: Hmac<Sha512>,
|
hmac_sha512: Hmac<Sha512>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl BIP32GrinHasher {
|
impl BIP32GrinHasher {
|
||||||
/// New empty hasher
|
/// New empty hasher
|
||||||
pub fn new() -> BIP32GrinHasher {
|
pub fn new(is_floo: bool) -> BIP32GrinHasher {
|
||||||
BIP32GrinHasher {
|
BIP32GrinHasher {
|
||||||
|
is_floo: is_floo,
|
||||||
hmac_sha512: HmacSha512::new(GenericArray::from_slice(&[0u8; 128])),
|
hmac_sha512: HmacSha512::new(GenericArray::from_slice(&[0u8; 128])),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl BIP32Hasher for BIP32GrinHasher {
|
impl BIP32Hasher for BIP32GrinHasher {
|
||||||
fn network_priv() -> [u8; 4] {
|
fn network_priv(&self) -> [u8; 4] {
|
||||||
// gprv
|
match self.is_floo {
|
||||||
[0x03, 0x3C, 0x04, 0xA4]
|
true => [0x03, 0x27, 0x3A, 0x10], // fprv
|
||||||
|
false => [0x03, 0x3C, 0x04, 0xA4], // gprv
|
||||||
|
}
|
||||||
}
|
}
|
||||||
fn network_pub() -> [u8; 4] {
|
fn network_pub(&self) -> [u8; 4] {
|
||||||
// gpub
|
match self.is_floo {
|
||||||
[0x03, 0x3C, 0x08, 0xDF]
|
true => [0x03, 0x27, 0x3E, 0x4B], // fpub
|
||||||
|
false => [0x03, 0x3C, 0x08, 0xDF], // gpub
|
||||||
|
}
|
||||||
}
|
}
|
||||||
fn master_seed() -> [u8; 12] {
|
fn master_seed() -> [u8; 12] {
|
||||||
b"IamVoldemort".to_owned()
|
b"IamVoldemort".to_owned()
|
||||||
|
@ -357,7 +364,7 @@ impl ExtendedPrivKey {
|
||||||
let result = hasher.result_sha512();
|
let result = hasher.result_sha512();
|
||||||
|
|
||||||
Ok(ExtendedPrivKey {
|
Ok(ExtendedPrivKey {
|
||||||
network: H::network_priv(),
|
network: hasher.network_priv(),
|
||||||
depth: 0,
|
depth: 0,
|
||||||
parent_fingerprint: Default::default(),
|
parent_fingerprint: Default::default(),
|
||||||
child_number: ChildNumber::from_normal_idx(0),
|
child_number: ChildNumber::from_normal_idx(0),
|
||||||
|
@ -371,12 +378,13 @@ impl ExtendedPrivKey {
|
||||||
secp: &Secp256k1,
|
secp: &Secp256k1,
|
||||||
mnemonic: &str,
|
mnemonic: &str,
|
||||||
passphrase: &str,
|
passphrase: &str,
|
||||||
|
is_floo: bool,
|
||||||
) -> Result<ExtendedPrivKey, Error> {
|
) -> Result<ExtendedPrivKey, Error> {
|
||||||
let seed = match mnemonic::to_seed(mnemonic, passphrase) {
|
let seed = match mnemonic::to_seed(mnemonic, passphrase) {
|
||||||
Ok(s) => s,
|
Ok(s) => s,
|
||||||
Err(e) => return Err(Error::MnemonicError(e)),
|
Err(e) => return Err(Error::MnemonicError(e)),
|
||||||
};
|
};
|
||||||
let mut hasher = BIP32GrinHasher::new();
|
let mut hasher = BIP32GrinHasher::new(is_floo);
|
||||||
let key = r#try!(ExtendedPrivKey::new_master(secp, &mut hasher, &seed));
|
let key = r#try!(ExtendedPrivKey::new_master(secp, &mut hasher, &seed));
|
||||||
Ok(key)
|
Ok(key)
|
||||||
}
|
}
|
||||||
|
@ -449,7 +457,7 @@ impl ExtendedPrivKey {
|
||||||
{
|
{
|
||||||
let secp = Secp256k1::with_caps(ContextFlag::SignOnly);
|
let secp = Secp256k1::with_caps(ContextFlag::SignOnly);
|
||||||
// Compute extended public key
|
// Compute extended public key
|
||||||
let pk: ExtendedPubKey = ExtendedPubKey::from_private::<H>(&secp, self);
|
let pk: ExtendedPubKey = ExtendedPubKey::from_private::<H>(&secp, self, hasher);
|
||||||
// Do SHA256 of just the ECDSA pubkey
|
// Do SHA256 of just the ECDSA pubkey
|
||||||
let sha2_res = hasher.sha_256(&pk.public_key.serialize_vec(&secp, true)[..]);
|
let sha2_res = hasher.sha_256(&pk.public_key.serialize_vec(&secp, true)[..]);
|
||||||
// do RIPEMD160
|
// do RIPEMD160
|
||||||
|
@ -469,12 +477,12 @@ impl ExtendedPrivKey {
|
||||||
|
|
||||||
impl ExtendedPubKey {
|
impl ExtendedPubKey {
|
||||||
/// Derives a public key from a private key
|
/// Derives a public key from a private key
|
||||||
pub fn from_private<H>(secp: &Secp256k1, sk: &ExtendedPrivKey) -> ExtendedPubKey
|
pub fn from_private<H>(secp: &Secp256k1, sk: &ExtendedPrivKey, hasher: &mut H) -> ExtendedPubKey
|
||||||
where
|
where
|
||||||
H: BIP32Hasher,
|
H: BIP32Hasher,
|
||||||
{
|
{
|
||||||
ExtendedPubKey {
|
ExtendedPubKey {
|
||||||
network: H::network_pub(),
|
network: hasher.network_pub(),
|
||||||
depth: sk.depth,
|
depth: sk.depth,
|
||||||
parent_fingerprint: sk.parent_fingerprint,
|
parent_fingerprint: sk.parent_fingerprint,
|
||||||
child_number: sk.child_number,
|
child_number: sk.child_number,
|
||||||
|
@ -696,11 +704,11 @@ mod tests {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl BIP32Hasher for BIP32ReferenceHasher {
|
impl BIP32Hasher for BIP32ReferenceHasher {
|
||||||
fn network_priv() -> [u8; 4] {
|
fn network_priv(&self) -> [u8; 4] {
|
||||||
// bitcoin network (xprv) (for test vectors)
|
// bitcoin network (xprv) (for test vectors)
|
||||||
[0x04, 0x88, 0xAD, 0xE4]
|
[0x04, 0x88, 0xAD, 0xE4]
|
||||||
}
|
}
|
||||||
fn network_pub() -> [u8; 4] {
|
fn network_pub(&self) -> [u8; 4] {
|
||||||
// bitcoin network (xpub) (for test vectors)
|
// bitcoin network (xpub) (for test vectors)
|
||||||
[0x04, 0x88, 0xB2, 0x1E]
|
[0x04, 0x88, 0xB2, 0x1E]
|
||||||
}
|
}
|
||||||
|
@ -743,7 +751,7 @@ mod tests {
|
||||||
) {
|
) {
|
||||||
let mut h = BIP32ReferenceHasher::new();
|
let mut h = BIP32ReferenceHasher::new();
|
||||||
let mut sk = ExtendedPrivKey::new_master(secp, &mut h, seed).unwrap();
|
let mut sk = ExtendedPrivKey::new_master(secp, &mut h, seed).unwrap();
|
||||||
let mut pk = ExtendedPubKey::from_private::<BIP32ReferenceHasher>(secp, &sk);
|
let mut pk = ExtendedPubKey::from_private::<BIP32ReferenceHasher>(secp, &sk, &mut h);
|
||||||
|
|
||||||
// Check derivation convenience method for ExtendedPrivKey
|
// Check derivation convenience method for ExtendedPrivKey
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
@ -771,7 +779,7 @@ mod tests {
|
||||||
match num {
|
match num {
|
||||||
ChildNumber::Normal { .. } => {
|
ChildNumber::Normal { .. } => {
|
||||||
let pk2 = pk.ckd_pub(secp, &mut h, num).unwrap();
|
let pk2 = pk.ckd_pub(secp, &mut h, num).unwrap();
|
||||||
pk = ExtendedPubKey::from_private::<BIP32ReferenceHasher>(secp, &sk);
|
pk = ExtendedPubKey::from_private::<BIP32ReferenceHasher>(secp, &sk, &mut h);
|
||||||
assert_eq!(pk, pk2);
|
assert_eq!(pk, pk2);
|
||||||
}
|
}
|
||||||
ChildNumber::Hardened { .. } => {
|
ChildNumber::Hardened { .. } => {
|
||||||
|
@ -779,7 +787,7 @@ mod tests {
|
||||||
pk.ckd_pub(secp, &mut h, num),
|
pk.ckd_pub(secp, &mut h, num),
|
||||||
Err(Error::CannotDeriveFromHardenedKey)
|
Err(Error::CannotDeriveFromHardenedKey)
|
||||||
);
|
);
|
||||||
pk = ExtendedPubKey::from_private::<BIP32ReferenceHasher>(secp, &sk);
|
pk = ExtendedPubKey::from_private::<BIP32ReferenceHasher>(secp, &sk, &mut h);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,37 +30,41 @@ pub struct ExtKeychain {
|
||||||
secp: Secp256k1,
|
secp: Secp256k1,
|
||||||
master: ExtendedPrivKey,
|
master: ExtendedPrivKey,
|
||||||
use_switch_commits: bool,
|
use_switch_commits: bool,
|
||||||
|
hasher: BIP32GrinHasher,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Keychain for ExtKeychain {
|
impl Keychain for ExtKeychain {
|
||||||
fn from_seed(seed: &[u8]) -> Result<ExtKeychain, Error> {
|
fn from_seed(seed: &[u8], is_floo: bool) -> Result<ExtKeychain, Error> {
|
||||||
let mut h = BIP32GrinHasher::new();
|
let mut h = BIP32GrinHasher::new(is_floo);
|
||||||
let secp = secp::Secp256k1::with_caps(secp::ContextFlag::Commit);
|
let secp = secp::Secp256k1::with_caps(secp::ContextFlag::Commit);
|
||||||
let master = ExtendedPrivKey::new_master(&secp, &mut h, seed)?;
|
let master = ExtendedPrivKey::new_master(&secp, &mut h, seed)?;
|
||||||
let keychain = ExtKeychain {
|
let keychain = ExtKeychain {
|
||||||
secp: secp,
|
secp: secp,
|
||||||
master: master,
|
master: master,
|
||||||
use_switch_commits: true,
|
use_switch_commits: true,
|
||||||
|
hasher: h,
|
||||||
};
|
};
|
||||||
Ok(keychain)
|
Ok(keychain)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn from_mnemonic(word_list: &str, extension_word: &str) -> Result<Self, Error> {
|
fn from_mnemonic(word_list: &str, extension_word: &str, is_floo: bool) -> Result<Self, Error> {
|
||||||
let secp = secp::Secp256k1::with_caps(secp::ContextFlag::Commit);
|
let secp = secp::Secp256k1::with_caps(secp::ContextFlag::Commit);
|
||||||
let master = ExtendedPrivKey::from_mnemonic(&secp, word_list, extension_word)?;
|
let h = BIP32GrinHasher::new(is_floo);
|
||||||
|
let master = ExtendedPrivKey::from_mnemonic(&secp, word_list, extension_word, is_floo)?;
|
||||||
let keychain = ExtKeychain {
|
let keychain = ExtKeychain {
|
||||||
secp: secp,
|
secp: secp,
|
||||||
master: master,
|
master: master,
|
||||||
use_switch_commits: true,
|
use_switch_commits: true,
|
||||||
|
hasher: h,
|
||||||
};
|
};
|
||||||
Ok(keychain)
|
Ok(keychain)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// For testing - probably not a good idea to use outside of tests.
|
/// For testing - probably not a good idea to use outside of tests.
|
||||||
fn from_random_seed() -> Result<ExtKeychain, Error> {
|
fn from_random_seed(is_floo: bool) -> Result<ExtKeychain, Error> {
|
||||||
let seed: String = thread_rng().sample_iter(&Alphanumeric).take(16).collect();
|
let seed: String = thread_rng().sample_iter(&Alphanumeric).take(16).collect();
|
||||||
let seed = blake2::blake2b::blake2b(32, &[], seed.as_bytes());
|
let seed = blake2::blake2b::blake2b(32, &[], seed.as_bytes());
|
||||||
ExtKeychain::from_seed(seed.as_bytes())
|
ExtKeychain::from_seed(seed.as_bytes(), is_floo)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn root_key_id() -> Identifier {
|
fn root_key_id() -> Identifier {
|
||||||
|
@ -72,7 +76,7 @@ impl Keychain for ExtKeychain {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn derive_key(&self, amount: u64, id: &Identifier) -> Result<SecretKey, Error> {
|
fn derive_key(&self, amount: u64, id: &Identifier) -> Result<SecretKey, Error> {
|
||||||
let mut h = BIP32GrinHasher::new();
|
let mut h = self.hasher.clone();
|
||||||
let p = id.to_path();
|
let p = id.to_path();
|
||||||
let mut ext_key = self.master;
|
let mut ext_key = self.master;
|
||||||
for i in 0..p.depth {
|
for i in 0..p.depth {
|
||||||
|
@ -172,7 +176,7 @@ mod test {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_key_derivation() {
|
fn test_key_derivation() {
|
||||||
let keychain = ExtKeychain::from_random_seed().unwrap();
|
let keychain = ExtKeychain::from_random_seed(false).unwrap();
|
||||||
let secp = keychain.secp();
|
let secp = keychain.secp();
|
||||||
|
|
||||||
let path = ExtKeychainPath::new(1, 1, 0, 0, 0);
|
let path = ExtKeychainPath::new(1, 1, 0, 0, 0);
|
||||||
|
@ -196,7 +200,7 @@ mod test {
|
||||||
// and summing the keys used to commit to 0 have the same result.
|
// and summing the keys used to commit to 0 have the same result.
|
||||||
#[test]
|
#[test]
|
||||||
fn secret_key_addition() {
|
fn secret_key_addition() {
|
||||||
let keychain = ExtKeychain::from_random_seed().unwrap();
|
let keychain = ExtKeychain::from_random_seed(false).unwrap();
|
||||||
|
|
||||||
let skey1 = SecretKey::from_slice(
|
let skey1 = SecretKey::from_slice(
|
||||||
&keychain.secp,
|
&keychain.secp,
|
||||||
|
|
|
@ -451,13 +451,13 @@ pub struct ValueExtKeychainPath {
|
||||||
pub trait Keychain: Sync + Send + Clone {
|
pub trait Keychain: Sync + Send + Clone {
|
||||||
/// Generates a keychain from a raw binary seed (which has already been
|
/// Generates a keychain from a raw binary seed (which has already been
|
||||||
/// decrypted if applicable).
|
/// decrypted if applicable).
|
||||||
fn from_seed(seed: &[u8]) -> Result<Self, Error>;
|
fn from_seed(seed: &[u8], is_floo: bool) -> Result<Self, Error>;
|
||||||
|
|
||||||
/// Generates a keychain from a list of space-separated mnemonic words
|
/// Generates a keychain from a list of space-separated mnemonic words
|
||||||
fn from_mnemonic(word_list: &str, extension_word: &str) -> Result<Self, Error>;
|
fn from_mnemonic(word_list: &str, extension_word: &str, is_floo: bool) -> Result<Self, Error>;
|
||||||
|
|
||||||
/// Generates a keychain from a randomly generated seed. Mostly used for tests.
|
/// Generates a keychain from a randomly generated seed. Mostly used for tests.
|
||||||
fn from_random_seed() -> Result<Self, Error>;
|
fn from_random_seed(is_floo: bool) -> Result<Self, Error>;
|
||||||
|
|
||||||
/// Root identifier for that keychain
|
/// Root identifier for that keychain
|
||||||
fn root_key_id() -> Identifier;
|
fn root_key_id() -> Identifier;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "grin_p2p"
|
name = "grin_p2p"
|
||||||
version = "0.4.2"
|
version = "0.5.0"
|
||||||
authors = ["Grin Developers <mimblewimble@lists.launchpad.net>"]
|
authors = ["Grin Developers <mimblewimble@lists.launchpad.net>"]
|
||||||
description = "Chain implementation for grin, a simple, private and scalable cryptocurrency implementation based on the MimbleWimble chain format."
|
description = "Chain implementation for grin, a simple, private and scalable cryptocurrency implementation based on the MimbleWimble chain format."
|
||||||
license = "Apache-2.0"
|
license = "Apache-2.0"
|
||||||
|
@ -22,9 +22,9 @@ serde_derive = "1"
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
chrono = { version = "0.4.4", features = ["serde"] }
|
chrono = { version = "0.4.4", features = ["serde"] }
|
||||||
|
|
||||||
grin_core = { path = "../core", version = "0.4.2" }
|
grin_core = { path = "../core", version = "0.5.0" }
|
||||||
grin_store = { path = "../store", version = "0.4.2" }
|
grin_store = { path = "../store", version = "0.5.0" }
|
||||||
grin_util = { path = "../util", version = "0.4.2" }
|
grin_util = { path = "../util", version = "0.5.0" }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
grin_pool = { path = "../pool", version = "0.4.2" }
|
grin_pool = { path = "../pool", version = "0.5.0" }
|
||||||
|
|
|
@ -19,11 +19,11 @@ use std::io::{Read, Write};
|
||||||
use std::net::{Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4, SocketAddrV6};
|
use std::net::{Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4, SocketAddrV6};
|
||||||
use std::time;
|
use std::time;
|
||||||
|
|
||||||
use crate::core::consensus;
|
|
||||||
use crate::core::core::hash::Hash;
|
use crate::core::core::hash::Hash;
|
||||||
use crate::core::core::BlockHeader;
|
use crate::core::core::BlockHeader;
|
||||||
use crate::core::pow::Difficulty;
|
use crate::core::pow::Difficulty;
|
||||||
use crate::core::ser::{self, FixedLength, Readable, Reader, StreamingReader, Writeable, Writer};
|
use crate::core::ser::{self, FixedLength, Readable, Reader, StreamingReader, Writeable, Writer};
|
||||||
|
use crate::core::{consensus, global};
|
||||||
use crate::types::{
|
use crate::types::{
|
||||||
Capabilities, Error, ReasonForBan, MAX_BLOCK_HEADERS, MAX_LOCATORS, MAX_PEER_ADDRS,
|
Capabilities, Error, ReasonForBan, MAX_BLOCK_HEADERS, MAX_LOCATORS, MAX_PEER_ADDRS,
|
||||||
};
|
};
|
||||||
|
@ -35,8 +35,10 @@ pub const PROTOCOL_VERSION: u32 = 1;
|
||||||
/// Grin's user agent with current version
|
/// Grin's user agent with current version
|
||||||
pub const USER_AGENT: &'static str = concat!("MW/Grin ", env!("CARGO_PKG_VERSION"));
|
pub const USER_AGENT: &'static str = concat!("MW/Grin ", env!("CARGO_PKG_VERSION"));
|
||||||
|
|
||||||
/// Magic number expected in the header of every message
|
/// Magic numbers expected in the header of every message
|
||||||
const MAGIC: [u8; 2] = [0x53, 0x35];
|
const OTHER_MAGIC: [u8; 2] = [73, 43];
|
||||||
|
const FLOONET_MAGIC: [u8; 2] = [83, 59];
|
||||||
|
const MAINNET_MAGIC: [u8; 2] = [97, 61];
|
||||||
|
|
||||||
/// Max theoretical size of a block filled with outputs.
|
/// Max theoretical size of a block filled with outputs.
|
||||||
const MAX_BLOCK_SIZE: u64 =
|
const MAX_BLOCK_SIZE: u64 =
|
||||||
|
@ -99,6 +101,14 @@ fn max_msg_size(msg_type: Type) -> u64 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn magic() -> [u8; 2] {
|
||||||
|
match *global::CHAIN_TYPE.read() {
|
||||||
|
global::ChainTypes::Floonet => FLOONET_MAGIC,
|
||||||
|
global::ChainTypes::Mainnet => MAINNET_MAGIC,
|
||||||
|
_ => OTHER_MAGIC,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Read a header from the provided stream without blocking if the
|
/// Read a header from the provided stream without blocking if the
|
||||||
/// underlying stream is async. Typically headers will be polled for, so
|
/// underlying stream is async. Typically headers will be polled for, so
|
||||||
/// we do not want to block.
|
/// we do not want to block.
|
||||||
|
@ -187,7 +197,7 @@ impl MsgHeader {
|
||||||
/// Creates a new message header.
|
/// Creates a new message header.
|
||||||
pub fn new(msg_type: Type, len: u64) -> MsgHeader {
|
pub fn new(msg_type: Type, len: u64) -> MsgHeader {
|
||||||
MsgHeader {
|
MsgHeader {
|
||||||
magic: MAGIC,
|
magic: magic(),
|
||||||
msg_type: msg_type,
|
msg_type: msg_type,
|
||||||
msg_len: len,
|
msg_len: len,
|
||||||
}
|
}
|
||||||
|
@ -213,12 +223,13 @@ impl Writeable for MsgHeader {
|
||||||
|
|
||||||
impl Readable for MsgHeader {
|
impl Readable for MsgHeader {
|
||||||
fn read(reader: &mut dyn Reader) -> Result<MsgHeader, ser::Error> {
|
fn read(reader: &mut dyn Reader) -> Result<MsgHeader, ser::Error> {
|
||||||
reader.expect_u8(MAGIC[0])?;
|
let m = magic();
|
||||||
reader.expect_u8(MAGIC[1])?;
|
reader.expect_u8(m[0])?;
|
||||||
|
reader.expect_u8(m[1])?;
|
||||||
let (t, len) = ser_multiread!(reader, read_u8, read_u64);
|
let (t, len) = ser_multiread!(reader, read_u8, read_u64);
|
||||||
match Type::from_u8(t) {
|
match Type::from_u8(t) {
|
||||||
Some(ty) => Ok(MsgHeader {
|
Some(ty) => Ok(MsgHeader {
|
||||||
magic: MAGIC,
|
magic: m,
|
||||||
msg_type: ty,
|
msg_type: ty,
|
||||||
msg_len: len,
|
msg_len: len,
|
||||||
}),
|
}),
|
||||||
|
|
|
@ -132,7 +132,7 @@ impl Default for P2PConfig {
|
||||||
let ipaddr = "0.0.0.0".parse().unwrap();
|
let ipaddr = "0.0.0.0".parse().unwrap();
|
||||||
P2PConfig {
|
P2PConfig {
|
||||||
host: ipaddr,
|
host: ipaddr,
|
||||||
port: 13414,
|
port: 3414,
|
||||||
capabilities: Capabilities::FULL_NODE,
|
capabilities: Capabilities::FULL_NODE,
|
||||||
seeding_type: Seeding::default(),
|
seeding_type: Seeding::default(),
|
||||||
seeds: None,
|
seeds: None,
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "grin_pool"
|
name = "grin_pool"
|
||||||
version = "0.4.2"
|
version = "0.5.0"
|
||||||
authors = ["Grin Developers <mimblewimble@lists.launchpad.net>"]
|
authors = ["Grin Developers <mimblewimble@lists.launchpad.net>"]
|
||||||
description = "Chain implementation for grin, a simple, private and scalable cryptocurrency implementation based on the MimbleWimble chain format."
|
description = "Chain implementation for grin, a simple, private and scalable cryptocurrency implementation based on the MimbleWimble chain format."
|
||||||
license = "Apache-2.0"
|
license = "Apache-2.0"
|
||||||
|
@ -17,10 +17,10 @@ serde_derive = "1"
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
chrono = "0.4.4"
|
chrono = "0.4.4"
|
||||||
|
|
||||||
grin_core = { path = "../core", version = "0.4.2" }
|
grin_core = { path = "../core", version = "0.5.0" }
|
||||||
grin_keychain = { path = "../keychain", version = "0.4.2" }
|
grin_keychain = { path = "../keychain", version = "0.5.0" }
|
||||||
grin_store = { path = "../store", version = "0.4.2" }
|
grin_store = { path = "../store", version = "0.5.0" }
|
||||||
grin_util = { path = "../util", version = "0.4.2" }
|
grin_util = { path = "../util", version = "0.5.0" }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
grin_chain = { path = "../chain", version = "0.4.2" }
|
grin_chain = { path = "../chain", version = "0.5.0" }
|
||||||
|
|
|
@ -30,7 +30,7 @@ use std::sync::Arc;
|
||||||
#[test]
|
#[test]
|
||||||
fn test_transaction_pool_block_building() {
|
fn test_transaction_pool_block_building() {
|
||||||
util::init_test_logger();
|
util::init_test_logger();
|
||||||
let keychain: ExtKeychain = Keychain::from_random_seed().unwrap();
|
let keychain: ExtKeychain = Keychain::from_random_seed(false).unwrap();
|
||||||
|
|
||||||
let db_root = ".grin_block_building".to_string();
|
let db_root = ".grin_block_building".to_string();
|
||||||
clean_output_dir(db_root.clone());
|
clean_output_dir(db_root.clone());
|
||||||
|
|
|
@ -30,7 +30,7 @@ use std::sync::Arc;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_transaction_pool_block_reconciliation() {
|
fn test_transaction_pool_block_reconciliation() {
|
||||||
let keychain: ExtKeychain = Keychain::from_random_seed().unwrap();
|
let keychain: ExtKeychain = Keychain::from_random_seed(false).unwrap();
|
||||||
|
|
||||||
let db_root = ".grin_block_reconciliation".to_string();
|
let db_root = ".grin_block_reconciliation".to_string();
|
||||||
clean_output_dir(db_root.clone());
|
clean_output_dir(db_root.clone());
|
||||||
|
|
|
@ -67,7 +67,7 @@ impl BlockChain for CoinbaseMaturityErrorChainAdapter {
|
||||||
/// Test we correctly verify coinbase maturity when adding txs to the pool.
|
/// Test we correctly verify coinbase maturity when adding txs to the pool.
|
||||||
#[test]
|
#[test]
|
||||||
fn test_coinbase_maturity() {
|
fn test_coinbase_maturity() {
|
||||||
let keychain: ExtKeychain = Keychain::from_random_seed().unwrap();
|
let keychain: ExtKeychain = Keychain::from_random_seed(false).unwrap();
|
||||||
|
|
||||||
// Mocking this up with an adapter that will raise an error for coinbase
|
// Mocking this up with an adapter that will raise an error for coinbase
|
||||||
// maturity.
|
// maturity.
|
||||||
|
|
|
@ -29,7 +29,7 @@ use std::sync::Arc;
|
||||||
/// Test we can add some txs to the pool (both stempool and txpool).
|
/// Test we can add some txs to the pool (both stempool and txpool).
|
||||||
#[test]
|
#[test]
|
||||||
fn test_the_transaction_pool() {
|
fn test_the_transaction_pool() {
|
||||||
let keychain: ExtKeychain = Keychain::from_random_seed().unwrap();
|
let keychain: ExtKeychain = Keychain::from_random_seed(false).unwrap();
|
||||||
|
|
||||||
let db_root = ".grin_transaction_pool".to_string();
|
let db_root = ".grin_transaction_pool".to_string();
|
||||||
clean_output_dir(db_root.clone());
|
clean_output_dir(db_root.clone());
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "grin_servers"
|
name = "grin_servers"
|
||||||
version = "0.4.2"
|
version = "0.5.0"
|
||||||
authors = ["Grin Developers <mimblewimble@lists.launchpad.net>"]
|
authors = ["Grin Developers <mimblewimble@lists.launchpad.net>"]
|
||||||
description = "Simple, private and scalable cryptocurrency implementation based on the MimbleWimble chain format."
|
description = "Simple, private and scalable cryptocurrency implementation based on the MimbleWimble chain format."
|
||||||
license = "Apache-2.0"
|
license = "Apache-2.0"
|
||||||
|
@ -25,15 +25,15 @@ chrono = "0.4.4"
|
||||||
bufstream = "~0.1"
|
bufstream = "~0.1"
|
||||||
jsonrpc-core = "~8.0"
|
jsonrpc-core = "~8.0"
|
||||||
|
|
||||||
grin_api = { path = "../api", version = "0.4.2" }
|
grin_api = { path = "../api", version = "0.5.0" }
|
||||||
grin_chain = { path = "../chain", version = "0.4.2" }
|
grin_chain = { path = "../chain", version = "0.5.0" }
|
||||||
grin_core = { path = "../core", version = "0.4.2" }
|
grin_core = { path = "../core", version = "0.5.0" }
|
||||||
grin_keychain = { path = "../keychain", version = "0.4.2" }
|
grin_keychain = { path = "../keychain", version = "0.5.0" }
|
||||||
grin_p2p = { path = "../p2p", version = "0.4.2" }
|
grin_p2p = { path = "../p2p", version = "0.5.0" }
|
||||||
grin_pool = { path = "../pool", version = "0.4.2" }
|
grin_pool = { path = "../pool", version = "0.5.0" }
|
||||||
grin_store = { path = "../store", version = "0.4.2" }
|
grin_store = { path = "../store", version = "0.5.0" }
|
||||||
grin_util = { path = "../util", version = "0.4.2" }
|
grin_util = { path = "../util", version = "0.5.0" }
|
||||||
grin_wallet = { path = "../wallet", version = "0.4.2" }
|
grin_wallet = { path = "../wallet", version = "0.5.0" }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
blake2-rfc = "0.2"
|
blake2-rfc = "0.2"
|
||||||
|
|
|
@ -172,7 +172,7 @@ impl Default for ServerConfig {
|
||||||
fn default() -> ServerConfig {
|
fn default() -> ServerConfig {
|
||||||
ServerConfig {
|
ServerConfig {
|
||||||
db_root: "grin_chain".to_string(),
|
db_root: "grin_chain".to_string(),
|
||||||
api_http_addr: "127.0.0.1:13413".to_string(),
|
api_http_addr: "127.0.0.1:3413".to_string(),
|
||||||
api_secret_path: Some(".api_secret".to_string()),
|
api_secret_path: Some(".api_secret".to_string()),
|
||||||
p2p_config: p2p::P2PConfig::default(),
|
p2p_config: p2p::P2PConfig::default(),
|
||||||
dandelion_config: pool::DandelionConfig::default(),
|
dandelion_config: pool::DandelionConfig::default(),
|
||||||
|
@ -218,12 +218,12 @@ pub struct StratumServerConfig {
|
||||||
impl Default for StratumServerConfig {
|
impl Default for StratumServerConfig {
|
||||||
fn default() -> StratumServerConfig {
|
fn default() -> StratumServerConfig {
|
||||||
StratumServerConfig {
|
StratumServerConfig {
|
||||||
wallet_listener_url: "http://127.0.0.1:13415".to_string(),
|
wallet_listener_url: "http://127.0.0.1:3415".to_string(),
|
||||||
burn_reward: false,
|
burn_reward: false,
|
||||||
attempt_time_per_block: 15,
|
attempt_time_per_block: 15,
|
||||||
minimum_share_difficulty: 1,
|
minimum_share_difficulty: 1,
|
||||||
enable_stratum_server: Some(false),
|
enable_stratum_server: Some(false),
|
||||||
stratum_server_addr: Some("127.0.0.1:13416".to_string()),
|
stratum_server_addr: Some("127.0.0.1:3416".to_string()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -335,7 +335,7 @@ fn listen_for_addrs(
|
||||||
pub fn dns_seeds() -> Box<dyn Fn() -> Vec<SocketAddr> + Send> {
|
pub fn dns_seeds() -> Box<dyn Fn() -> Vec<SocketAddr> + Send> {
|
||||||
Box::new(|| {
|
Box::new(|| {
|
||||||
let mut addresses: Vec<SocketAddr> = vec![];
|
let mut addresses: Vec<SocketAddr> = vec![];
|
||||||
let net_seeds = if global::is_testnet() {
|
let net_seeds = if global::is_floonet() {
|
||||||
FLOONET_DNS_SEEDS
|
FLOONET_DNS_SEEDS
|
||||||
} else {
|
} else {
|
||||||
MAINNET_DNS_SEEDS
|
MAINNET_DNS_SEEDS
|
||||||
|
|
|
@ -25,7 +25,7 @@ use std::time::Duration;
|
||||||
use crate::chain;
|
use crate::chain;
|
||||||
use crate::common::types::Error;
|
use crate::common::types::Error;
|
||||||
use crate::core::core::verifier_cache::VerifierCache;
|
use crate::core::core::verifier_cache::VerifierCache;
|
||||||
use crate::core::{consensus, core, ser};
|
use crate::core::{consensus, core, global, ser};
|
||||||
use crate::keychain::{ExtKeychain, Identifier, Keychain};
|
use crate::keychain::{ExtKeychain, Identifier, Keychain};
|
||||||
use crate::pool;
|
use crate::pool;
|
||||||
use crate::util;
|
use crate::util;
|
||||||
|
@ -170,11 +170,10 @@ fn build_block(
|
||||||
///
|
///
|
||||||
fn burn_reward(block_fees: BlockFees) -> Result<(core::Output, core::TxKernel, BlockFees), Error> {
|
fn burn_reward(block_fees: BlockFees) -> Result<(core::Output, core::TxKernel, BlockFees), Error> {
|
||||||
warn!("Burning block fees: {:?}", block_fees);
|
warn!("Burning block fees: {:?}", block_fees);
|
||||||
let keychain = ExtKeychain::from_random_seed().unwrap();
|
let keychain = ExtKeychain::from_random_seed(global::is_floonet()).unwrap();
|
||||||
let key_id = ExtKeychain::derive_key_id(1, 1, 0, 0, 0);
|
let key_id = ExtKeychain::derive_key_id(1, 1, 0, 0, 0);
|
||||||
let (out, kernel) =
|
let (out, kernel) =
|
||||||
crate::core::libtx::reward::output(&keychain, &key_id, block_fees.fees)
|
crate::core::libtx::reward::output(&keychain, &key_id, block_fees.fees).unwrap();
|
||||||
.unwrap();
|
|
||||||
Ok((out, kernel, block_fees))
|
Ok((out, kernel, block_fees))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -306,7 +306,7 @@ impl LocalServerContainer {
|
||||||
wallet_seed: &wallet::WalletSeed,
|
wallet_seed: &wallet::WalletSeed,
|
||||||
) -> wallet::WalletInfo {
|
) -> wallet::WalletInfo {
|
||||||
let keychain: keychain::ExtKeychain = wallet_seed
|
let keychain: keychain::ExtKeychain = wallet_seed
|
||||||
.derive_keychain()
|
.derive_keychain(false)
|
||||||
.expect("Failed to derive keychain from seed file and passphrase.");
|
.expect("Failed to derive keychain from seed file and passphrase.");
|
||||||
let client_n = HTTPNodeClient::new(&config.check_node_api_http_addr, None);
|
let client_n = HTTPNodeClient::new(&config.check_node_api_http_addr, None);
|
||||||
let mut wallet = LMDBBackend::new(config.clone(), "", client_n)
|
let mut wallet = LMDBBackend::new(config.clone(), "", client_n)
|
||||||
|
@ -332,7 +332,7 @@ impl LocalServerContainer {
|
||||||
wallet::WalletSeed::from_file(config, "").expect("Failed to read wallet seed file.");
|
wallet::WalletSeed::from_file(config, "").expect("Failed to read wallet seed file.");
|
||||||
|
|
||||||
let keychain: keychain::ExtKeychain = wallet_seed
|
let keychain: keychain::ExtKeychain = wallet_seed
|
||||||
.derive_keychain()
|
.derive_keychain(false)
|
||||||
.expect("Failed to derive keychain from seed file and passphrase.");
|
.expect("Failed to derive keychain from seed file and passphrase.");
|
||||||
|
|
||||||
let client_n = HTTPNodeClient::new(&config.check_node_api_http_addr, None);
|
let client_n = HTTPNodeClient::new(&config.check_node_api_http_addr, None);
|
||||||
|
|
|
@ -14,11 +14,12 @@
|
||||||
|
|
||||||
/// Grin configuration file output command
|
/// Grin configuration file output command
|
||||||
use crate::config::{GlobalConfig, GlobalWalletConfig};
|
use crate::config::{GlobalConfig, GlobalWalletConfig};
|
||||||
|
use crate::core::global;
|
||||||
use std::env;
|
use std::env;
|
||||||
|
|
||||||
/// Create a config file in the current directory
|
/// Create a config file in the current directory
|
||||||
pub fn config_command_server(file_name: &str) {
|
pub fn config_command_server(chain_type: &global::ChainTypes, file_name: &str) {
|
||||||
let mut default_config = GlobalConfig::default();
|
let mut default_config = GlobalConfig::for_chain(chain_type);
|
||||||
let current_dir = env::current_dir().unwrap_or_else(|e| {
|
let current_dir = env::current_dir().unwrap_or_else(|e| {
|
||||||
panic!("Error creating config file: {}", e);
|
panic!("Error creating config file: {}", e);
|
||||||
});
|
});
|
||||||
|
@ -44,8 +45,8 @@ pub fn config_command_server(file_name: &str) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create a config file in the current directory
|
/// Create a config file in the current directory
|
||||||
pub fn config_command_wallet(file_name: &str) {
|
pub fn config_command_wallet(chain_type: &global::ChainTypes, file_name: &str) {
|
||||||
let mut default_config = GlobalWalletConfig::default();
|
let mut default_config = GlobalWalletConfig::for_chain(chain_type);
|
||||||
let current_dir = env::current_dir().unwrap_or_else(|e| {
|
let current_dir = env::current_dir().unwrap_or_else(|e| {
|
||||||
panic!("Error creating config file: {}", e);
|
panic!("Error creating config file: {}", e);
|
||||||
});
|
});
|
||||||
|
|
|
@ -79,12 +79,26 @@ fn real_main() -> i32 {
|
||||||
let mut wallet_config = None;
|
let mut wallet_config = None;
|
||||||
let mut node_config = None;
|
let mut node_config = None;
|
||||||
|
|
||||||
|
let chain_type = if args.is_present("floonet") {
|
||||||
|
global::ChainTypes::Floonet
|
||||||
|
} else if args.is_present("usernet") {
|
||||||
|
global::ChainTypes::UserTesting
|
||||||
|
} else {
|
||||||
|
global::ChainTypes::Mainnet
|
||||||
|
};
|
||||||
|
|
||||||
|
// TODO remove for mainnet
|
||||||
|
if chain_type == global::ChainTypes::Mainnet {
|
||||||
|
println!("Mainnet not ready yet! In the meantime run 'grin --floonet ...'");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
// Deal with configuration file creation
|
// Deal with configuration file creation
|
||||||
match args.subcommand() {
|
match args.subcommand() {
|
||||||
("server", Some(server_args)) => {
|
("server", Some(server_args)) => {
|
||||||
// If it's just a server config command, do it and exit
|
// If it's just a server config command, do it and exit
|
||||||
if let ("config", Some(_)) = server_args.subcommand() {
|
if let ("config", Some(_)) = server_args.subcommand() {
|
||||||
cmd::config_command_server(SERVER_CONFIG_FILE_NAME);
|
cmd::config_command_server(&chain_type, SERVER_CONFIG_FILE_NAME);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -93,7 +107,7 @@ fn real_main() -> i32 {
|
||||||
// (if desired)
|
// (if desired)
|
||||||
if let ("init", Some(init_args)) = wallet_args.subcommand() {
|
if let ("init", Some(init_args)) = wallet_args.subcommand() {
|
||||||
if init_args.is_present("here") {
|
if init_args.is_present("here") {
|
||||||
cmd::config_command_wallet(WALLET_CONFIG_FILE_NAME);
|
cmd::config_command_wallet(&chain_type, WALLET_CONFIG_FILE_NAME);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -103,7 +117,7 @@ fn real_main() -> i32 {
|
||||||
match args.subcommand() {
|
match args.subcommand() {
|
||||||
// If it's a wallet command, try and load a wallet config file
|
// If it's a wallet command, try and load a wallet config file
|
||||||
("wallet", Some(wallet_args)) => {
|
("wallet", Some(wallet_args)) => {
|
||||||
let mut w = config::initial_setup_wallet().unwrap_or_else(|e| {
|
let mut w = config::initial_setup_wallet(&chain_type).unwrap_or_else(|e| {
|
||||||
panic!("Error loading wallet configuration: {}", e);
|
panic!("Error loading wallet configuration: {}", e);
|
||||||
});
|
});
|
||||||
if !cmd::seed_exists(w.members.as_ref().unwrap().wallet.clone()) {
|
if !cmd::seed_exists(w.members.as_ref().unwrap().wallet.clone()) {
|
||||||
|
@ -124,7 +138,7 @@ fn real_main() -> i32 {
|
||||||
}
|
}
|
||||||
// Otherwise load up the node config as usual
|
// Otherwise load up the node config as usual
|
||||||
_ => {
|
_ => {
|
||||||
let mut s = config::initial_setup_server().unwrap_or_else(|e| {
|
let mut s = config::initial_setup_server(&chain_type).unwrap_or_else(|e| {
|
||||||
panic!("Error loading server configuration: {}", e);
|
panic!("Error loading server configuration: {}", e);
|
||||||
});
|
});
|
||||||
let mut l = s.members.as_mut().unwrap().logging.clone().unwrap();
|
let mut l = s.members.as_mut().unwrap().logging.clone().unwrap();
|
||||||
|
|
|
@ -1,8 +1,17 @@
|
||||||
name: grin
|
name: grin
|
||||||
version: "0.4.2"
|
version: "0.5.0"
|
||||||
about: Lightweight implementation of the MimbleWimble protocol.
|
about: Lightweight implementation of the MimbleWimble protocol.
|
||||||
author: The Grin Team
|
author: The Grin Team
|
||||||
|
|
||||||
|
args:
|
||||||
|
- floonet:
|
||||||
|
help: Run grin against the Floonet (as opposed to mainnet)
|
||||||
|
long: floonet
|
||||||
|
takes_value: false
|
||||||
|
- usernet:
|
||||||
|
help: Run grin as a local-only network. Doesn't block peer connections but will not connect to any peer or seed
|
||||||
|
long: usernet
|
||||||
|
takes_value: false
|
||||||
subcommands:
|
subcommands:
|
||||||
- server:
|
- server:
|
||||||
about: Control the Grin server
|
about: Control the Grin server
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "grin_store"
|
name = "grin_store"
|
||||||
version = "0.4.2"
|
version = "0.5.0"
|
||||||
authors = ["Grin Developers <mimblewimble@lists.launchpad.net>"]
|
authors = ["Grin Developers <mimblewimble@lists.launchpad.net>"]
|
||||||
description = "Simple, private and scalable cryptocurrency implementation based on the MimbleWimble chain format."
|
description = "Simple, private and scalable cryptocurrency implementation based on the MimbleWimble chain format."
|
||||||
license = "Apache-2.0"
|
license = "Apache-2.0"
|
||||||
|
@ -22,8 +22,8 @@ serde = "1"
|
||||||
serde_derive = "1"
|
serde_derive = "1"
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
|
|
||||||
grin_core = { path = "../core", version = "0.4.2" }
|
grin_core = { path = "../core", version = "0.5.0" }
|
||||||
grin_util = { path = "../util", version = "0.4.2" }
|
grin_util = { path = "../util", version = "0.5.0" }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
chrono = "0.4.4"
|
chrono = "0.4.4"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "grin_util"
|
name = "grin_util"
|
||||||
version = "0.4.2"
|
version = "0.5.0"
|
||||||
authors = ["Grin Developers <mimblewimble@lists.launchpad.net>"]
|
authors = ["Grin Developers <mimblewimble@lists.launchpad.net>"]
|
||||||
description = "Simple, private and scalable cryptocurrency implementation based on the MimbleWimble chain format."
|
description = "Simple, private and scalable cryptocurrency implementation based on the MimbleWimble chain format."
|
||||||
license = "Apache-2.0"
|
license = "Apache-2.0"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "grin_wallet"
|
name = "grin_wallet"
|
||||||
version = "0.4.2"
|
version = "0.5.0"
|
||||||
authors = ["Grin Developers <mimblewimble@lists.launchpad.net>"]
|
authors = ["Grin Developers <mimblewimble@lists.launchpad.net>"]
|
||||||
description = "Simple, private and scalable cryptocurrency implementation based on the MimbleWimble chain format."
|
description = "Simple, private and scalable cryptocurrency implementation based on the MimbleWimble chain format."
|
||||||
license = "Apache-2.0"
|
license = "Apache-2.0"
|
||||||
|
@ -31,13 +31,13 @@ uuid = { version = "0.6", features = ["serde", "v4"] }
|
||||||
url = "1.7.0"
|
url = "1.7.0"
|
||||||
chrono = { version = "0.4.4", features = ["serde"] }
|
chrono = { version = "0.4.4", features = ["serde"] }
|
||||||
|
|
||||||
grin_api = { path = "../api", version = "0.4.2" }
|
grin_api = { path = "../api", version = "0.5.0" }
|
||||||
grin_core = { path = "../core", version = "0.4.2" }
|
grin_core = { path = "../core", version = "0.5.0" }
|
||||||
grin_keychain = { path = "../keychain", version = "0.4.2" }
|
grin_keychain = { path = "../keychain", version = "0.5.0" }
|
||||||
grin_store = { path = "../store", version = "0.4.2" }
|
grin_store = { path = "../store", version = "0.5.0" }
|
||||||
grin_util = { path = "../util", version = "0.4.2" }
|
grin_util = { path = "../util", version = "0.5.0" }
|
||||||
grin_chain = { path = "../chain", version = "0.4.2" }
|
grin_chain = { path = "../chain", version = "0.5.0" }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
grin_store = { path = "../store", version = "0.4.2" }
|
grin_store = { path = "../store", version = "0.5.0" }
|
||||||
grin_config = { path = "../config", version = "0.4.2" }
|
grin_config = { path = "../config", version = "0.5.0" }
|
||||||
|
|
|
@ -233,7 +233,7 @@ mod test {
|
||||||
// demonstrate that input.commitment == referenced output.commitment
|
// demonstrate that input.commitment == referenced output.commitment
|
||||||
// based on the public key and amount begin spent
|
// based on the public key and amount begin spent
|
||||||
fn output_commitment_equals_input_commitment_on_spend() {
|
fn output_commitment_equals_input_commitment_on_spend() {
|
||||||
let keychain = ExtKeychain::from_random_seed().unwrap();
|
let keychain = ExtKeychain::from_random_seed(false).unwrap();
|
||||||
let key_id1 = ExtKeychainPath::new(1, 1, 0, 0, 0).to_identifier();
|
let key_id1 = ExtKeychainPath::new(1, 1, 0, 0, 0).to_identifier();
|
||||||
|
|
||||||
let tx1 = build::transaction(vec![build::output(105, key_id1.clone())], &keychain).unwrap();
|
let tx1 = build::transaction(vec![build::output(105, key_id1.clone())], &keychain).unwrap();
|
||||||
|
|
|
@ -32,7 +32,7 @@ use crate::keychain::{ChildNumber, ExtKeychain, Identifier, Keychain};
|
||||||
use crate::store::{self, option_to_not_found, to_key, to_key_u64};
|
use crate::store::{self, option_to_not_found, to_key, to_key_u64};
|
||||||
|
|
||||||
use crate::core::core::Transaction;
|
use crate::core::core::Transaction;
|
||||||
use crate::core::ser;
|
use crate::core::{global, ser};
|
||||||
use crate::libwallet::types::*;
|
use crate::libwallet::types::*;
|
||||||
use crate::libwallet::{internal, Error, ErrorKind};
|
use crate::libwallet::{internal, Error, ErrorKind};
|
||||||
use crate::types::{WalletConfig, WalletSeed};
|
use crate::types::{WalletConfig, WalletSeed};
|
||||||
|
@ -179,7 +179,7 @@ where
|
||||||
.context(ErrorKind::CallbackImpl("Error opening wallet"))?;
|
.context(ErrorKind::CallbackImpl("Error opening wallet"))?;
|
||||||
self.keychain = Some(
|
self.keychain = Some(
|
||||||
wallet_seed
|
wallet_seed
|
||||||
.derive_keychain()
|
.derive_keychain(global::is_floonet())
|
||||||
.context(ErrorKind::CallbackImpl("Error deriving keychain"))?,
|
.context(ErrorKind::CallbackImpl("Error deriving keychain"))?,
|
||||||
);
|
);
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
@ -66,10 +66,10 @@ impl Default for WalletConfig {
|
||||||
WalletConfig {
|
WalletConfig {
|
||||||
chain_type: Some(ChainTypes::Floonet),
|
chain_type: Some(ChainTypes::Floonet),
|
||||||
api_listen_interface: "127.0.0.1".to_string(),
|
api_listen_interface: "127.0.0.1".to_string(),
|
||||||
api_listen_port: 13415,
|
api_listen_port: 3415,
|
||||||
api_secret_path: Some(".api_secret".to_string()),
|
api_secret_path: Some(".api_secret".to_string()),
|
||||||
node_api_secret_path: Some(".api_secret".to_string()),
|
node_api_secret_path: Some(".api_secret".to_string()),
|
||||||
check_node_api_http_addr: "http://127.0.0.1:13413".to_string(),
|
check_node_api_http_addr: "http://127.0.0.1:3413".to_string(),
|
||||||
data_file_dir: ".".to_string(),
|
data_file_dir: ".".to_string(),
|
||||||
tls_certificate_file: None,
|
tls_certificate_file: None,
|
||||||
tls_certificate_key: None,
|
tls_certificate_key: None,
|
||||||
|
@ -124,8 +124,8 @@ impl WalletSeed {
|
||||||
seed.as_bytes().to_vec()
|
seed.as_bytes().to_vec()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn derive_keychain<K: Keychain>(&self) -> Result<K, Error> {
|
pub fn derive_keychain<K: Keychain>(&self, is_floonet: bool) -> Result<K, Error> {
|
||||||
let result = K::from_seed(&self.0)?;
|
let result = K::from_seed(&self.0, is_floonet)?;
|
||||||
Ok(result)
|
Ok(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -218,36 +218,7 @@ impl WalletSeed {
|
||||||
let mut buffer = String::new();
|
let mut buffer = String::new();
|
||||||
file.read_to_string(&mut buffer).context(ErrorKind::IO)?;
|
file.read_to_string(&mut buffer).context(ErrorKind::IO)?;
|
||||||
let enc_seed: EncryptedWalletSeed =
|
let enc_seed: EncryptedWalletSeed =
|
||||||
match serde_json::from_str(&buffer).context(ErrorKind::Format) {
|
serde_json::from_str(&buffer).context(ErrorKind::Format)?;
|
||||||
Ok(s) => s,
|
|
||||||
Err(_) => {
|
|
||||||
println!("Attempting to convert old wallet seed file to new format");
|
|
||||||
// TODO: remove for mainnet
|
|
||||||
// try to convert from old format
|
|
||||||
let mut bak_file = File::create(format!("{}.bak", seed_file_path))
|
|
||||||
.context(ErrorKind::IO)?;
|
|
||||||
let mut file = File::create(seed_file_path).context(ErrorKind::IO)?;
|
|
||||||
let old_wallet_seed = WalletSeed::from_hex(&buffer.trim())?;
|
|
||||||
bak_file
|
|
||||||
.write_all(&old_wallet_seed.to_hex().as_bytes())
|
|
||||||
.context(ErrorKind::IO)?;
|
|
||||||
let mut c_wallet_seed = [0u8; 32];
|
|
||||||
c_wallet_seed.copy_from_slice(&old_wallet_seed.0[0..32]);
|
|
||||||
let converted_wallet_seed =
|
|
||||||
WalletSeed::derive_keychain_old(c_wallet_seed, password);
|
|
||||||
let enc_seed = EncryptedWalletSeed::from_seed(
|
|
||||||
&WalletSeed::from_bytes(&converted_wallet_seed),
|
|
||||||
password,
|
|
||||||
)?;
|
|
||||||
let enc_seed_json =
|
|
||||||
serde_json::to_string_pretty(&enc_seed).context(ErrorKind::Format)?;
|
|
||||||
file.write_all(&enc_seed_json.as_bytes())
|
|
||||||
.context(ErrorKind::IO)?;
|
|
||||||
println!("Seed file conversion done");
|
|
||||||
println!("Consider moving funds to a newly-created wallet to support recovery phrases");
|
|
||||||
enc_seed
|
|
||||||
}
|
|
||||||
};
|
|
||||||
let wallet_seed = enc_seed.decrypt(password)?;
|
let wallet_seed = enc_seed.decrypt(password)?;
|
||||||
Ok(wallet_seed)
|
Ok(wallet_seed)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -31,8 +31,8 @@ fn kernel_sig_msg() -> secp::Message {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn aggsig_sender_receiver_interaction() {
|
fn aggsig_sender_receiver_interaction() {
|
||||||
let sender_keychain = ExtKeychain::from_random_seed().unwrap();
|
let sender_keychain = ExtKeychain::from_random_seed(true).unwrap();
|
||||||
let receiver_keychain = ExtKeychain::from_random_seed().unwrap();
|
let receiver_keychain = ExtKeychain::from_random_seed(true).unwrap();
|
||||||
|
|
||||||
// Calculate the kernel excess here for convenience.
|
// Calculate the kernel excess here for convenience.
|
||||||
// Normally this would happen during transaction building.
|
// Normally this would happen during transaction building.
|
||||||
|
@ -41,7 +41,7 @@ fn aggsig_sender_receiver_interaction() {
|
||||||
let skey1 = sender_keychain.derive_key(0, &id1).unwrap();
|
let skey1 = sender_keychain.derive_key(0, &id1).unwrap();
|
||||||
let skey2 = receiver_keychain.derive_key(0, &id1).unwrap();
|
let skey2 = receiver_keychain.derive_key(0, &id1).unwrap();
|
||||||
|
|
||||||
let keychain = ExtKeychain::from_random_seed().unwrap();
|
let keychain = ExtKeychain::from_random_seed(true).unwrap();
|
||||||
let blinding_factor = keychain
|
let blinding_factor = keychain
|
||||||
.blind_sum(
|
.blind_sum(
|
||||||
&BlindSum::new()
|
&BlindSum::new()
|
||||||
|
@ -224,7 +224,7 @@ fn aggsig_sender_receiver_interaction() {
|
||||||
|
|
||||||
// Check we can verify the sig using the kernel excess
|
// Check we can verify the sig using the kernel excess
|
||||||
{
|
{
|
||||||
let keychain = ExtKeychain::from_random_seed().unwrap();
|
let keychain = ExtKeychain::from_random_seed(true).unwrap();
|
||||||
let msg = kernel_sig_msg();
|
let msg = kernel_sig_msg();
|
||||||
let sig_verifies =
|
let sig_verifies =
|
||||||
aggsig::verify_single_from_commit(&keychain.secp(), &final_sig, &msg, &kernel_excess);
|
aggsig::verify_single_from_commit(&keychain.secp(), &final_sig, &msg, &kernel_excess);
|
||||||
|
@ -235,8 +235,8 @@ fn aggsig_sender_receiver_interaction() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn aggsig_sender_receiver_interaction_offset() {
|
fn aggsig_sender_receiver_interaction_offset() {
|
||||||
let sender_keychain = ExtKeychain::from_random_seed().unwrap();
|
let sender_keychain = ExtKeychain::from_random_seed(true).unwrap();
|
||||||
let receiver_keychain = ExtKeychain::from_random_seed().unwrap();
|
let receiver_keychain = ExtKeychain::from_random_seed(true).unwrap();
|
||||||
|
|
||||||
// This is the kernel offset that we use to split the key
|
// This is the kernel offset that we use to split the key
|
||||||
// Summing these at the block level prevents the
|
// Summing these at the block level prevents the
|
||||||
|
@ -250,7 +250,7 @@ fn aggsig_sender_receiver_interaction_offset() {
|
||||||
let skey1 = sender_keychain.derive_key(0, &id1).unwrap();
|
let skey1 = sender_keychain.derive_key(0, &id1).unwrap();
|
||||||
let skey2 = receiver_keychain.derive_key(0, &id1).unwrap();
|
let skey2 = receiver_keychain.derive_key(0, &id1).unwrap();
|
||||||
|
|
||||||
let keychain = ExtKeychain::from_random_seed().unwrap();
|
let keychain = ExtKeychain::from_random_seed(true).unwrap();
|
||||||
let blinding_factor = keychain
|
let blinding_factor = keychain
|
||||||
.blind_sum(
|
.blind_sum(
|
||||||
&BlindSum::new()
|
&BlindSum::new()
|
||||||
|
@ -439,7 +439,7 @@ fn aggsig_sender_receiver_interaction_offset() {
|
||||||
|
|
||||||
// Check we can verify the sig using the kernel excess
|
// Check we can verify the sig using the kernel excess
|
||||||
{
|
{
|
||||||
let keychain = ExtKeychain::from_random_seed().unwrap();
|
let keychain = ExtKeychain::from_random_seed(true).unwrap();
|
||||||
let msg = kernel_sig_msg();
|
let msg = kernel_sig_msg();
|
||||||
let sig_verifies =
|
let sig_verifies =
|
||||||
aggsig::verify_single_from_commit(&keychain.secp(), &final_sig, &msg, &kernel_excess);
|
aggsig::verify_single_from_commit(&keychain.secp(), &final_sig, &msg, &kernel_excess);
|
||||||
|
@ -450,7 +450,7 @@ fn aggsig_sender_receiver_interaction_offset() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_rewind_range_proof() {
|
fn test_rewind_range_proof() {
|
||||||
let keychain = ExtKeychain::from_random_seed().unwrap();
|
let keychain = ExtKeychain::from_random_seed(true).unwrap();
|
||||||
let key_id = ExtKeychain::derive_key_id(1, 1, 0, 0, 0);
|
let key_id = ExtKeychain::derive_key_id(1, 1, 0, 0, 0);
|
||||||
let key_id2 = ExtKeychain::derive_key_id(1, 2, 0, 0, 0);
|
let key_id2 = ExtKeychain::derive_key_id(1, 2, 0, 0, 0);
|
||||||
let commit = keychain.commit(5, &key_id).unwrap();
|
let commit = keychain.commit(5, &key_id).unwrap();
|
||||||
|
|
Loading…
Reference in a new issue