I'm attempting to transfer funds from the root account to another account on a private stellar network. When I attempt to run the code below (which is basically copied from the examples), I get an error that says the following when I sign the transaction:
hash tx failed: empty network passphrase
The full code is below, where did I go wrong?
package main
import (
"fmt"
"github.com/pkg/errors"
"log"
"net/http"
b "github.com/stellar/go/build"
"github.com/stellar/go/clients/horizon"
"github.com/stellar/go/keypair"
)
func main() {
// Root account seed, found in the startup log
from := "XXXXXXXXXXXXXXXXXXXXXXXXX"
pair, err := keypair.Random()
if err != nil {
log.Fatal(err)
}
// Create a new account keypair
to := pair.Address()
client := &horizon.Client{
URL: "http://127.0.0.1:8000",
HTTP: http.DefaultClient,
}
tx, herr := b.Transaction(
b.SourceAccount{AddressOrSeed: from},
b.DefaultNetwork,
b.AutoSequence{SequenceProvider: client},
b.Payment(
b.Destination{AddressOrSeed: to},
b.NativeAmount{Amount: "100"},
),
)
if herr != nil {
//panic(herr.(horizon.Error).Problem.Type)
panic(errors.WithStack(herr))
}
txe, err := tx.Sign(from)
if err != nil {
panic(err)
}
txe64, err := txe.Base64()
if err != nil {
panic(err)
}
fmt.Printf("tx base64: %s", txe64)
resp, err := horizon.DefaultTestNetClient.SubmitTransaction(txe64)
if err != nil {
panic(err)
}
fmt.Println("transaction posted in ledger:", resp.Ledger)
}