Index: nano.tcl ================================================================== --- nano.tcl +++ nano.tcl @@ -651,21 +651,21 @@ } proc ::nano::account::addPending {account blockHash amount} { set accountPubKey [::nano::address::toPublicKey $account -hex] - set ::nano::account::pending([list $accountPubKey $blockHash]) [dict create amount $amount] + dict set ::nano::account::pending $accountPubKey $blockHash amount $amount } proc ::nano::account::receive {account blockHash signKey} { set accountPubKey [::nano::address::toPublicKey $account -hex] set frontierInfo [getFrontier $account] dict with frontierInfo {} - set blockInfo $::nano::account::pending([list $accountPubKey $blockHash]) - unset ::nano::account::pending([list $accountPubKey $blockHash]) + set blockInfo [dict get $::nano::account::pending $accountPubKey $blockHash] + dict unset ::nano::account::pending $accountPubKey $blockHash set amount [dict get $blockInfo amount] set blockArgs [list to $account previousBalance $balance \ amount $amount sourceBlock $blockHash \ signKey $signKey representative $representative] @@ -713,20 +713,25 @@ addPending $toAccount $newFrontierHash $amount return $block } -proc ::nano::account::receiveAllPending {key} { +proc ::nano::account::receiveAllPending {key {accountPubKey ""}} { set outBlocks [list] - set accountPubKey [::nano::key::publicKeyFromPrivateKey $key -hex] + if {$accountPubKey eq ""} { + set accountPubKey [::nano::key::publicKeyFromPrivateKey $key -hex] + } + + if {![dict exists $::nano::account::pending $accountPubKey]} { + return $outBlocks + } set signKey [binary encode hex $key] set account [::nano::address::fromPublicKey $accountPubKey] - foreach accountPubKeyBlockHash [array names ::nano::account::pending [list $accountPubKey *]] { - set blockHash [lindex $accountPubKeyBlockHash 1] + foreach blockHash [dict keys [dict get $::nano::account::pending $accountPubKey]] { lappend outBlocks [receive $account $blockHash $signKey] } return $outBlocks }