Diff

Differences From Artifact [8dfa10c41c]:

To Artifact [d4333092df]:


649
650
651
652
653
654
655
656

657
658
659
660
661
662
663
664
665
666


667
668
669
670
671
672
673
649
650
651
652
653
654
655

656
657
658
659
660
661
662
663
664


665
666
667
668
669
670
671
672
673







-
+








-
-
+
+








	return [dict get $frontier {*}$args]
}

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]

	if {[info exists frontierHash]} {
711
712
713
714
715
716
717
718

719
720

721






722
723
724
725
726

727
728
729
730
731
732
711
712
713
714
715
716
717

718
719
720
721

722
723
724
725
726
727
728
729
730
731

732

733
734
735
736
737







-
+


+
-
+
+
+
+
+
+




-
+
-






	setFrontier $fromAccount $newFrontierHash $newBalance $fromRepresentative
	addPending  $toAccount $newFrontierHash $amount

	return $block
}

proc ::nano::account::receiveAllPending {key} {
proc ::nano::account::receiveAllPending {key {accountPubKey ""}} {
	set outBlocks [list]

	if {$accountPubKey eq ""} {
	set accountPubKey [::nano::key::publicKeyFromPrivateKey $key -hex]
		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 *]] {
	foreach blockHash [dict keys [dict get $::nano::account::pending $accountPubKey]] {
		set blockHash [lindex $accountPubKeyBlockHash 1]
		lappend outBlocks [receive $account $blockHash $signKey]
	}

	return $outBlocks
}