Diff

Differences From Artifact [a24cee35a4]:

To Artifact [30e8cf2947]:


26
27
28
29
30
31
32

33
34
35
36
37
38
39
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::_cli {}

# Constants
set ::nano::block::genesis(main) {{
	"type": "open",
	"source": "E89208DD038FBB269987689621D52292AE9C35941A7484756ECCED92A65093BA",
	"representative": "xrb_3t6k35gi95xu6tergt6p69ck76ogmitsa8mnijtpxm9fkcm736xtoncuohr3",







>







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

	tailcall $proc {*}$args
}

proc {::nano::_cli::multiword help} {namespace base args} {
	tailcall help $namespace $base {*}$args
}


































# 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
}







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







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
}