Rename TxOutput.amount -> TxOutput.value

This commit is contained in:
Mark Spanbroek 2021-06-30 12:37:33 +02:00
parent a7ef3b6b34
commit 96908b01b5
2 changed files with 6 additions and 6 deletions

View File

@ -19,7 +19,7 @@ type
owner: PublicKey
TxOutput* = tuple
owner: PublicKey
amount: UInt256
value: UInt256
TxHash* = distinct MDigest[256]
func `==`*(a, b: TxHash): bool {.borrow.}
@ -60,9 +60,9 @@ func toBytes*(transaction: Transaction): seq[byte] =
result.add(txHash.toBytes)
result.add(owner.toBytes)
result.add(transaction.outputs.len.uint8)
for (owner, amount) in transaction.outputs:
for (owner, value) in transaction.outputs:
result.add(owner.toBytes)
result.add(amount.toBytes)
result.add(value.toBytes)
func hash*(transaction: Transaction): TxHash =
TxHash(sha256.digest(transaction.toBytes))

View File

@ -6,10 +6,10 @@ func checkValue(store: TxStore, transaction: Transaction): bool =
for (hash, owner) in transaction.inputs:
for output in store[hash].outputs:
if output.owner == owner:
valueIn += output.amount
valueIn += output.value
for (_, amount) in transaction.outputs:
valueOut += amount
for (_, value) in transaction.outputs:
valueOut += value
valueIn == valueOut