Skip to content
This repository has been archived by the owner on Nov 22, 2022. It is now read-only.

Go SDK tx type is always p2p #1

Open
skyf0xx opened this issue Aug 19, 2021 · 4 comments
Open

Go SDK tx type is always p2p #1

skyf0xx opened this issue Aug 19, 2021 · 4 comments

Comments

@skyf0xx
Copy link

skyf0xx commented Aug 19, 2021

Transactions sent with the GoSDK always come through as p2p - other types do not seem to change the tx registered by the API

@m4thfr34k
Copy link

Occurs even when using the current version of the Kin Go SDK. - github.com/kinecosystem/kin-go v0.8.0

Code snippet is below.
Transactions produced have a memo that is automatically set by the SubmitPayment function. AppIndex is included in client.New and transactions are showing up in the Kin Developer Portal.

kinClient, err := client.New(client.EnvironmentProd, client.WithAppIndex(KreechuresAppIndexNumber))
resultFromEarnTransaction, err := kinClient.SubmitPayment(context.Background(), client.Payment{
   Sender:      priv,
   Destination: userTokenAccount,
   Type:        kin.TransactionTypeEarn,
   Quarks:      kin.MustToQuarks(strconv.Itoa(achievementAmount)),
}, client.WithSenderCreate())

@m4thfr34k
Copy link

package main

// This is a full example for this issue
// Issue existed prior to kin-go v0.8.0 and still exists

import (
"context"
"fmt"
"log"
"strconv"
"time"

"github.com/kinecosystem/agora-common/kin"
"github.com/kinecosystem/kin-go/client"

)

func main() {

var (
	// Byte array has been removed for submission to Github issues but follows the pattern below
	sender kin.PrivateKey = []byte{1,2,3,4,5,6}

	//App index changed for submission to Github issues
	MyExampleAppIndex = 123
)


c, err := client.New(client.EnvironmentProd, client.WithAppIndex(uint16(MyExampleAppIndex)), client.WithMaxRetries(0))
if err != nil {
	log.Fatal(err)
}

destAddress, _ := kin.NewPrivateKey()

fmt.Printf("Current Unix Time: %v\n", time.Now().Unix())
time.Sleep(45 * time.Second)
fmt.Printf("Current Unix Time: %v\n", time.Now().Unix())

// Create a new account for destination
err = c.CreateAccount(context.Background(), destAddress)
if err != nil {
	log.Fatal(err)
}

fmt.Println("sender ->",sender.Public().Base58())
fmt.Println("dest ->",destAddress.Public().Base58())

fmt.Printf("Current Unix Time: %v\n", time.Now().Unix())
time.Sleep(45 * time.Second)
fmt.Printf("Current Unix Time: %v\n", time.Now().Unix())

quarks, err := c.GetBalance(context.Background(), sender.Public())
fmt.Println("Priv Address ->", sender.Public().Base58())
fmt.Println("Priv Quarks  ->", quarks)


quarks, err = c.GetBalance(context.Background(), destAddress.Public())
fmt.Println("Priv Address ->", destAddress.Public().Base58())
fmt.Println("Priv Quarks  ->", quarks)

// Payment with no invoicing.
txHash, err := c.SubmitPayment(context.Background(), client.Payment{
	Sender: sender,
	Destination: destAddress.Public(),
	Type: kin.TransactionTypeEarn,
	// Note: should use client.KinToQuarks when using non-constants.
	Quarks: kin.MustToQuarks(strconv.Itoa(100)),
}, client.WithSenderCreate())

fmt.Printf("Hash: %x, err: %v\n", txHash, err)

}

@m4thfr34k
Copy link

module KinEarnIssue

go 1.16

//go mod file for example above

// This dependency of stellar/go no longer exists; use a forked version of the repo instead.
replace bitbucket.org/ww/goautoneg => github.com/adjust/goautoneg v0.0.0-20150426214442-d788f35a0315

require (
github.com/google/uuid v1.3.0 // indirect
github.com/kinecosystem/agora-api v0.28.0 // indirect
github.com/kinecosystem/agora-common v0.85.0
github.com/kinecosystem/go v0.0.0-20191108204735-d6832148266e // indirect
github.com/kinecosystem/kin-go v0.8.0
)

@skyf0xx
Copy link
Author

skyf0xx commented Oct 18, 2021

I have noticed some apps in the back end with only p2p transactions showing up, even though I know they have earns. This could possibly be the cause.

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

No branches or pull requests

2 participants