bigchaindb / go-bigchaindb-driver

Official Go BigchainDB driver
Apache License 2.0
11 stars 13 forks source link

PostTransaction function returns Request Unsuccessful 426 #4

Open muhammadramis opened 6 years ago

muhammadramis commented 6 years ago

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 {

    }