本文整理汇总了Golang中github.com/stellar/go-stellar-base/xdr.Transaction类的典型用法代码示例。如果您正苦于以下问题:Golang Transaction类的具体用法?Golang Transaction怎么用?Golang Transaction使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Transaction类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: MutateTransaction
// MutateTransaction for PaymentBuilder causes the underylying PaymentOp
// to be added to the operation list for the provided transaction
func (m PaymentBuilder) MutateTransaction(o *xdr.Transaction) error {
if m.Err != nil {
return m.Err
}
m.O.Body = xdr.NewOperationBodyPayment(m.P)
o.Operations = append(o.Operations, m.O)
return nil
}
开发者ID:jacksonh,项目名称:go-horizon,代码行数:11,代码来源:transaction.go
示例2: SignAndSubmitRawTransaction
// SignAndSubmitRawTransaction will:
// - update sequence number of the transaction to the current one,
// - sign it,
// - submit it to the network.
func (ts *TransactionSubmitter) SignAndSubmitRawTransaction(seed string, tx *xdr.Transaction) (response horizon.SubmitTransactionResponse, err error) {
account, err := ts.GetAccount(seed)
if err != nil {
return
}
account.Mutex.Lock()
account.SequenceNumber++
tx.SeqNum = xdr.SequenceNumber(account.SequenceNumber)
account.Mutex.Unlock()
hash, err := TransactionHash(tx, ts.Network.Passphrase)
if err != nil {
ts.log.Print("Error calculating transaction hash")
return
}
sig, err := account.Keypair.SignDecorated(hash[:])
if err != nil {
ts.log.Print("Error signing a transaction")
return
}
envelopeXdr := xdr.TransactionEnvelope{
Tx: *tx,
Signatures: []xdr.DecoratedSignature{sig},
}
txeB64, err := xdr.MarshalBase64(envelopeXdr)
if err != nil {
ts.log.Print("Cannot encode transaction envelope")
return
}
transactionHashBytes, err := TransactionHash(tx, ts.Network.Passphrase)
if err != nil {
ts.log.WithFields(logrus.Fields{"err": err}).Warn("Error calculating tx hash")
return
}
sentTransaction := &entities.SentTransaction{
TransactionID: hex.EncodeToString(transactionHashBytes[:]),
Status: entities.SentTransactionStatusSending,
Source: account.Keypair.Address(),
SubmittedAt: ts.now(),
EnvelopeXdr: txeB64,
}
err = ts.EntityManager.Persist(sentTransaction)
if err != nil {
return
}
response, err = ts.Horizon.SubmitTransaction(txeB64)
if err != nil {
ts.log.Error("Error submitting transaction ", err)
return
}
if response.Ledger != nil {
sentTransaction.MarkSucceeded(*response.Ledger)
} else {
var result string
if response.Extras != nil {
result = response.Extras.ResultXdr
} else {
result = "<empty>"
}
sentTransaction.MarkFailed(result)
}
err = ts.EntityManager.Persist(sentTransaction)
if err != nil {
return
}
// Sync sequence number
if response.Extras != nil && response.Extras.ResultXdr == "AAAAAAAAAAD////7AAAAAA==" {
account.Mutex.Lock()
ts.log.Print("Syncing sequence number for ", account.Keypair.Address())
accountResponse, err2 := ts.Horizon.LoadAccount(account.Keypair.Address())
if err2 != nil {
ts.log.Error("Error updating sequence number ", err)
} else {
account.SequenceNumber, _ = strconv.ParseUint(accountResponse.SequenceNumber, 10, 64)
}
account.Mutex.Unlock()
}
return
}
开发者ID:FihlaTV,项目名称:bridge-server,代码行数:92,代码来源:transaction_submitter.go
示例3: MutateTransaction
// MutateTransaction for SourceAccount sets the transaction's SourceAccount
// to the pubilic key for the address provided
func (m Defaults) MutateTransaction(o *xdr.Transaction) error {
o.Fee = 10
memo, err := xdr.NewMemo(xdr.MemoTypeMemoNone, nil)
o.Memo = memo
return err
}
开发者ID:lackac,项目名称:horizon,代码行数:8,代码来源:transaction.go
注:本文中的github.com/stellar/go-stellar-base/xdr.Transaction类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论