Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PostTransaction function returns Request Unsuccessful 426 #4

Open
muhammadramis opened this issue Nov 16, 2018 · 0 comments
Open

PostTransaction function returns Request Unsuccessful 426 #4

muhammadramis opened this issue Nov 16, 2018 · 0 comments

Comments

@muhammadramis
Copy link

I am using golang, and upon posting a transaction the server is returning a 426.
this is the code i am using as an example.


cfg := cl.ClientConfig{
		Url: "http://192.168.100.10/api/v1/",
	}
	client, _ := cl.New(cfg)
	var data transaction.Asset
	data.Data = make(map[string]interface{})
	data.Data["test"] = "hello world"
	metadata := make(map[string]interface{})
	metadata["test"] = "hello world"
	var outputs []transaction.Output
	var issuers []ed25519.PublicKey
	var keyPairs []*transaction.KeyPair
	keyPair, err := transaction.NewKeyPair()
	fmt.Println(err)
	keyPairs = append(keyPairs, keyPair)
	for _, keyPair := range keyPairs {
		condition := transaction.NewEd25519Condition(keyPair.PublicKey)
		output, err := transaction.NewOutput(*condition, "1")
		if err != nil {
			fmt.Println("Cannot Create outputput!")
		}
		outputs = append(outputs, output)

		//Create Issuers

		issuers = append(issuers, keyPair.PublicKey)
	}
	txn, err := transaction.NewCreateTransaction(data, metadata, outputs, issuers)
	if err != nil {
		fmt.Println(err)
	} else {
		err = txn.Sign(keyPairs)
		if err != nil {
			fmt.Printf("Not Signed ! %s\n", err.Error())
		} else {
			fmt.Println("*** SIGNED TXN:")
			fmt.Println(txn.String())
		}
	}
	block1, err := client.GetBlock("0")
	if err != nil {
		fmt.Println("get block failed")
		fmt.Println(err)
	} else {
		fmt.Println(block1.Height)
	}
	err = client.PostTransaction(txn)
	if err != nil {
		fmt.Printf("Failed : %s\n", err.Error())
	} else {

	}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant