Overview
Comment: | Added support for decoding wallet backups |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
fe9b42ed610089c614cbd47eef2847e8 |
User & Date: | rkeene on 2019-01-11 17:47:37 |
Other Links: | manifest | tags |
Context
2019-01-11
| ||
17:50 | Use the user-supplied password check-in: b74e661b68 user: rkeene tags: trunk | |
17:47 | Added support for decoding wallet backups check-in: fe9b42ed61 user: rkeene tags: trunk | |
17:35 | randomSortList in the internal namespace check-in: 75052adbef user: rkeene tags: trunk | |
Changes
Modified nano.tcl from [a24cee35a4] to [30e8cf2947].
︙ | |||
26 27 28 29 30 31 32 33 34 35 36 37 38 39 | 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | + | namespace eval ::nano::node::cli {} namespace eval ::nano::network::client {} namespace eval ::nano::network::server {} namespace eval ::nano::protocol::create {} namespace eval ::nano::protocol::parse {} namespace eval ::nano::protocol::extensions {} namespace eval ::nano::network::_dns {} namespace eval ::nano::wallet {} namespace eval ::nano::_cli {} # Constants set ::nano::block::genesis(main) {{ "type": "open", "source": "E89208DD038FBB269987689621D52292AE9C35941A7484756ECCED92A65093BA", "representative": "xrb_3t6k35gi95xu6tergt6p69ck76ogmitsa8mnijtpxm9fkcm736xtoncuohr3", |
︙ | |||
4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 | 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | tailcall $proc {*}$args } proc {::nano::_cli::multiword help} {namespace base args} { tailcall help $namespace $base {*}$args } # Node Wallet Functions proc ::nano::wallet::decode_backup {password walletJSON} { array set walletArray [::json::json2dict $walletJSON] set wallet(version) [expr 0x$walletArray(0000000000000000000000000000000000000000000000000000000000000000)] set wallet(salt) [binary decode hex $walletArray(0000000000000000000000000000000000000000000000000000000000000001)] set wallet(key) [binary decode hex $walletArray(0000000000000000000000000000000000000000000000000000000000000002)] set wallet(check) [binary decode hex $walletArray(0000000000000000000000000000000000000000000000000000000000000003)] set wallet(rep) [::nano::address::fromPublicKey $walletArray(0000000000000000000000000000000000000000000000000000000000000004)] set wallet(seed) [binary decode hex $walletArray(0000000000000000000000000000000000000000000000000000000000000005)] set wallet(index) [expr 0x$walletArray(0000000000000000000000000000000000000000000000000000000000000006)] if {$wallet(version) != 4} { return -code error "Unsupported wallet backup version ($version)" } set password "" set walletKeyIV [string range $wallet(salt) 0 15] set seedIV [string range $wallet(salt) 16 end] # Decrypt seed set aesKey [::nano::internal::deriveKeyFromPassword $password $wallet(salt)] set walletKey [::nano::internal::AES256-CTR $aesKey $walletKeyIV $wallet(key)] set seed [::nano::internal::AES256-CTR $walletKey $seedIV $wallet(seed)] # Format results set wallet(seed) [string toupper [binary encode hex $seed]] # XXX:TODO: Include ad-hoc keys return [array get wallet] } # Node CLI proc ::nano::node::cli {args} { tailcall ::nano::_cli node -prompt { return "\[[dict get $::nano::node::configuration network]\] nano-node [package present nano]> " } {*}$args } |
︙ |
Modified test/test.tcl from [bdbaa835f7] to [e88f43aa2a].
︙ | |||
414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 | 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 | + + + + + + + + + + + + + + + + + + + + + + + + | puts "\[7.FAIL\] Got: $balance" puts "\[7.FAIL\] Exp: $balance_expected" return false } return true } proc test_wallet {} { set expectedSeed "7ED0C65229A00520A9CDD2C18C1172EFDF34467A8785E5D8D30916E4F6122273" set walletJSON {{ "0000000000000000000000000000000000000000000000000000000000000000": "0000000000000000000000000000000000000000000000000000000000000004", "0000000000000000000000000000000000000000000000000000000000000001": "F551DD44FC8A78D40BAF56ACD96390251246ADE5C805778EB54F3F28B84A8C84", "0000000000000000000000000000000000000000000000000000000000000002": "520E57026946425A4E1FF5596BF8B1D325AE43C63C11CC357CB598F8C934765A", "0000000000000000000000000000000000000000000000000000000000000003": "D28BBF12ADEB7C066205BEDA7F37904BD86B311DDE0FD06481144EBC89B00790", "0000000000000000000000000000000000000000000000000000000000000004": "2399A083C600AA0572F5E36247D978FCFC840405F8D4B6D33161C0066A55F431", "0000000000000000000000000000000000000000000000000000000000000005": "685FCF7537EE1AA8055638C5C278FBBEE77C0242D8A6F054534E476EE33F33FF", "0000000000000000000000000000000000000000000000000000000000000006": "0000000000000000000000000000000000000000000000000000000000000000" }} array set wallet [::nano::wallet::decode_backup "" $walletJSON] if {$wallet(seed) ne $expectedSeed} { puts "\[1.FAIL\] Got: $wallet(seed)" puts "\[1.FAIL\] Exp: $expectedSeed" return false } return true } set tests { selftest signatures hashing keygeneration addressformat blocks work balances wallet } foreach test $tests { puts -nonewline "\[ \] $test" flush stdout if {[catch { |
︙ |