Hot answers tagged

5

Just use Client.StreamLedgers method: client := DefaultPublicNetClient cursor := Cursor("now") // Call `cancel()` to stop streaming ctx, cancel := context.WithCancel(context.Background()) err := client.StreamLedgers(ctx, &cursor, func(l Ledger) { fmt.Println(l.Sequence) }) if err != nil { fmt.Println(err) }


3

There is no support yet for building a txnbuild.Transaction object from a xdr.TransactionEnvelope in the Go SDK. However, you can still sign the transaction by using this work around: https://play.golang.org/p/tr6y1Gim_4d See code below as well package main import ( "bytes" "encoding/base64" "fmt" "github.com/stellar/go/keypair" "...


3

It looks like the SignatureHint for hash(x) in your transaction is invalid. Signature hint for hash(x) is the 4 last bytes of the hash, not the preimage. Fix required around: Hint: xdr.SignatureHint(Hint(key)), The sha256 hash is equal: de30cab57041840f20d7df031d9704b2ddafeb408d52f2fe18f0a77aef511df5 So the hint should be equal ef511df5 but it's d7d888f2....


3

I'm just going to guess here, since I don't do golang, but if you look at what Sign does, can't you just copy that implementation yourself, and skip the signing part? I.e., func (b *TransactionBuilder) Sign(signers ...string) (TransactionEnvelopeBuilder, error) { var result TransactionEnvelopeBuilder err := result.Mutate(b) if err != nil { ...


3

You could use the spread operator on an object of type []build.TransactionMutator that is passed into the build.Transaction method (on github.com/stellar/go/build). Here's a code sample: import ( “github.com/stellar/go/build" ) // BuildWithOps builds a transaction with a dynamic list of operations func BuildWithOps(sourceAccount string, seq uint64, ...


2

This is how i convert the XDR before the initial signature. trustTx, err := build.Transaction( build.SourceAccount{recipient.Address()}, build.AutoSequence{SequenceProvider: horizon.DefaultTestNetClient}, build.TestNetwork, build.Trust(Asset.Code, Asset.Issuer, build.Limit(cd.Limit)), ) var result build.TransactionEnvelopeBuilder err := ...


2

I now understand that you have to build the transaction yourself using build. Example if anyone else gets stuck: import ( build "github.com/stellar/go/build" "github.com/stellar/go/clients/horizon" ) var b = []byte("Hello, goodbye, etc!") tx, err := build.Transaction( build.SourceAccount{AddressOrSeed: accountId}, build.TestNetwork, ...


2

The horizon internal package is not the right ones to use. It implements the server side. Like the js-stellar-sdk you will need to do an api call to horizon: curl "https://horizon-testnet.stellar.org/operations?limit=200&order=desc" The clients/horizon package is the client library for Go with helper methods. Edit There is no support for the ...


2

Support for this has now been added to the SDK in txnbuild 1.4. Here's an example that produces the same output as the previous lower-level workaround: https://play.golang.org/p/5uXzCEK_bgc package main import ( "fmt" "github.com/stellar/go/txnbuild" "github.com/stellar/go/network" ) func main() { // An existing Base 64 serialised ...


2

I'm not user of go, but I think the logic is the same for every language. Here's how I do: I get the transaction sources accounts and compute the list of legit signers for this transaction, then I search for the one which can verify each signature. Actually in JS SDK we can use the "hint" that give a clue (4 letters) about signer public key, but it's not ...


1

var txe xdr.Transaction err = xdr.SafeUnmarshalBase64(TDP.XDR, &txe) if err != nil { fmt.Println(err) } You can use above code to Unmarshal Base64 XDR. And using &txe you can retrieve what ever value you need.


1

This has been resolved, I'm unsure whether this was just a timing issue (where I needed to be more patient) or if I needed to install mercurial. Steps I used for resolution brew install mercurial brew update mercurial go get bitbucket.org/ww/goautoneg git config --global url."git@bitbucket.org:".insteadOf "https://bitbucket.org/" dep ensure -v After 10 ...


1

I have some examples for that in my kotlin library that wraps the java sdk. data class PreparedTransaction(val transactionHash: String, val transactionEnvelopeXdr: String) fun preparePaymentTransaction( sender: KeyPair, receiver: KeyPair, amount: TokenAmount, asset: Asset = amount.asset ?: nativeXlmAsset, memo: String? = null ): ...


1

I found the answer. Hopefully it will help someone in the future. muts := []build.TransactionMutator{ build.SourceAccount{recipient.Address()}, build.TestNetwork, build.AutoSequence{SequenceProvider: horizon.DefaultTestNetClient}, build.Payment( build.SourceAccount{Reciver2}, build.Destination{AddressOrSeed: recipient....


1

I figured that I needed to implement my own SequenceProvider looking at https://github.com/stellar/go/blob/master/clients/horizon/main.go#L20 and https://github.com/stellar/go/blob/master/clients/horizon/main.go#L108 and https://github.com/stellar/go/blob/master/clients/horizon/main.go#L111


1

The only thing that comes to my mind is that your node actually synced with the publicly available test network and applied the history. That's why the master account's (GBRPYHIL2CI3FNQ4BXLFMNDLFJUNPU2HY3ZMFSHONUCEOASW7QC7OX2H) sequence number is higher than 1 and you're getting tx_bad_seq. If you want to create a fully isolated network change ...


Only top voted, non community-wiki answers of a minimum length are eligible