Skip to content

Transaction built with wrong hash #165

@davidatwhiletrue

Description

@davidatwhiletrue

What happened?

Building a transaction results in a json object with a wrong computed hash.

What did you expect to happen?

Correct hash

Are you willing to submit a pull request to fix this bug?

STR:

	packageHash, _ := casper.NewHash(tokenPackage)
	entryPoint := "approve"

	senderKey, _ := casper.NewPublicKey(sender)

	minterKey, _ := casper.NewKey("hash-" + v.minterPackage)
	clSpender := clvalue.NewCLKey(minterKey)
	clAmountToken := clvalue.NewCLUInt256(big.NewInt(int64(amountToken)))

	args := &types.Args{}
	args.AddArgument("spender", clSpender)
	args.AddArgument("amount", *clAmountToken)

	payload, err := types.NewTransactionV1Payload(
		types.InitiatorAddr{
			PublicKey: &senderKey,
		},
		types.Timestamp(time.Now().UTC()),
		900000000000,
		v.chainName,
		types.PricingMode{
			Limited: &types.LimitedMode{
				GasPriceTolerance: 1,
				StandardPayment:   true,
				PaymentAmount:     v.paymentFee,
			},
		},
		types.NewNamedArgs(args),
		types.TransactionTarget{
			Stored: &types.StoredTarget{
				ID: types.TransactionInvocationTarget{
					ByPackageHash: &types.ByPackageHashInvocationTarget{
						Addr:    packageHash,
						Version: nil,
					},
				},
				Runtime: types.NewVmCasperV1TransactionRuntime(),
			},
		},
		types.TransactionEntryPoint{
			Custom: &entryPoint,
		},
		types.TransactionScheduling{
			Standard: &struct{}{},
		},
	)
	if err != nil {
		return nil, nil, fmt.Errorf("failed to create transaction payload: %w", err)
	}

	transaction, err := types.MakeTransactionV1(payload)
	if err != nil {
		return nil, nil, fmt.Errorf("failed to create transaction: %w", err)
	}

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions