func extractEnvelopeInfo(ctx context.Context, env string, passphrase string) (result envelopeInfo, err error) { var tx xdr.TransactionEnvelope err = xdr.SafeUnmarshalBase64(env, &tx) if err != nil { err = &MalformedTransactionError{env} return } txb := build.TransactionBuilder{TX: &tx.Tx} txb.Mutate(build.Network{passphrase}) result.Hash, err = txb.HashHex() if err != nil { return } result.Sequence = uint64(tx.Tx.SeqNum) aid := tx.Tx.SourceAccount.MustEd25519() result.SourceAddress, err = strkey.Encode(strkey.VersionByteAccountID, aid[:]) return }
func (this *StellarAccountMerge) GetSigned(seed string) string { tx := build.TransactionBuilder{} tx.TX = &xdr.Transaction{} opt := xdr.Operation{} srcAccID, _ := stellarbase.AddressToAccountId(this.SrcInfo.ID) destAccID, _ := stellarbase.AddressToAccountId(this.DestPublicAddr) opt.SourceAccount = &srcAccID opt.Body, _ = xdr.NewOperationBody(xdr.OperationTypeAccountMerge, destAccID) tx.TX.Operations = append(tx.TX.Operations, opt) tx.Mutate(build.Sequence{xdr.SequenceNumber(this.SrcInfo.NextSequence())}) if STELLAR_DEFAULT_NETWORK == STELLAR_TEST_NETWORK { tx.Mutate(build.TestNetwork) } else { tx.Mutate(build.PublicNetwork) } tx.Mutate(build.SourceAccount{this.SrcInfo.ID}) tx.TX.Fee = BASEMENT_FEE result := tx.Sign(seed) var err error this.signBase64, err = result.Base64() // fmt.Printf("tx base64: %s\r\n", this.signBase64) if err == nil { return this.signBase64 } fmt.Println(err) return "" }
func (this *StellarAccountCreateInfo) GetSigned(seed string) string { // _, spriv, _ := stellarbase.GenerateKeyFromSeed(seed) // kp,_ := keypair.Parse(seed) tx := build.TransactionBuilder{} ca := build.CreateAccountBuilder{} ca.Mutate(build.Destination{this.Destinaton}) ca.Mutate(build.SourceAccount{this.SrcInfo.ID}) ca.Mutate(build.NativeAmount{fmt.Sprintf("%f", this.Amount)}) tx.Mutate(build.Sequence{xdr.SequenceNumber(this.SrcInfo.NextSequence())}) if STELLAR_DEFAULT_NETWORK == STELLAR_TEST_NETWORK { tx.Mutate(build.TestNetwork) } else { tx.Mutate(build.PublicNetwork) } tx.Mutate(ca) tx.Mutate(build.SourceAccount{this.SrcInfo.ID}) tx.TX.Fee = BASEMENT_FEE // result := tx.Sign(&spriv) result := tx.Sign(seed) var err error this.signBase64, err = result.Base64() // fmt.Printf("tx base64: %s\r\n", this.signBase64) if err == nil { return this.signBase64 } fmt.Println(err) return "" }