Skip to content
Snippets Groups Projects
Commit 4bfcb797 authored by Hans Moog's avatar Hans Moog
Browse files

Feat: bundleHash gets calculated for value bundles

parent 97a87d17
No related branches found
No related tags found
No related merge requests found
package bundleprocessor
import (
"github.com/iotadevelopment/go/packages/ternary"
"github.com/iotaledger/goshimmer/packages/curl"
"github.com/iotaledger/goshimmer/packages/errors"
"github.com/iotaledger/goshimmer/packages/model/bundle"
"github.com/iotaledger/goshimmer/packages/model/transactionmetadata"
......@@ -54,12 +54,18 @@ func ProcessSolidBundleHead(headTransaction *value_transaction.ValueTransaction)
newBundle.SetTransactionHashes(mapTransactionsToTransactionHashes(bundleTransactions))
if newBundle.IsValueBundle() {
var concatenatedBundleEssences = make(ternary.Trits, len(bundleTransactions)*value_transaction.BUNDLE_ESSENCE_SIZE)
var concatenatedBundleEssences = make(trinary.Trits, len(bundleTransactions)*value_transaction.BUNDLE_ESSENCE_SIZE)
for i, bundleTransaction := range bundleTransactions {
copy(concatenatedBundleEssences[value_transaction.BUNDLE_ESSENCE_SIZE*i:value_transaction.BUNDLE_ESSENCE_SIZE*(i+1)], bundleTransaction.GetBundleEssence())
}
// calc + set bundle hash
var resp = make(trinary.Trits, 243)
hasher := curl.NewCurl(243, 81)
hasher.Absorb(concatenatedBundleEssences, 0, len(concatenatedBundleEssences))
hasher.Squeeze(resp, 0, 243)
newBundle.SetBundleEssenceHash(trinary.MustTritsToTrytes(resp))
}
Events.BundleSolid.Trigger(newBundle, bundleTransactions)
......
......@@ -29,6 +29,7 @@ func TestProcessSolidBundleHead(t *testing.T) {
Events.BundleSolid.Attach(events.NewClosure(func(bundle *bundle.Bundle, transactions []*value_transaction.ValueTransaction) {
fmt.Println("IT HAPPENED")
fmt.Println(bundle.GetHash())
fmt.Println(bundle.GetBundleEssenceHash())
}))
result, err := ProcessSolidBundleHead(tx1)
......
......@@ -8,7 +8,6 @@ import (
"github.com/iotaledger/goshimmer/plugins/bundleprocessor"
"github.com/iotaledger/iota.go/address"
. "github.com/iotaledger/iota.go/consts"
"github.com/iotaledger/iota.go/kerl"
"github.com/iotaledger/iota.go/signing"
. "github.com/iotaledger/iota.go/trinary"
)
......@@ -63,7 +62,7 @@ func validateSignatures(bundleHash Hash, txs []*value_transaction.ValueTransacti
}
// validate all the fragments against the address using Kerl
valid, err := signing.ValidateSignatures(address, fragments, bundleHash, kerl.NewKerl())
valid, err := signing.ValidateSignatures(address, fragments, bundleHash, signing.NewKerl)
if err != nil {
return false, err
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment