本文整理汇总了Golang中github.com/stellar/go-stellar-base/xdr.NewOperationBody函数的典型用法代码示例。如果您正苦于以下问题:Golang NewOperationBody函数的具体用法?Golang NewOperationBody怎么用?Golang NewOperationBody使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewOperationBody函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: MutateTransaction
// MutateTransaction for ManageOfferBuilder causes the underylying
// ManageData to be added to the operation list for the provided
// transaction
func (m ManageOfferBuilder) MutateTransaction(o *TransactionBuilder) error {
if m.Err != nil {
return m.Err
}
if m.PassiveOffer {
m.O.Body, m.Err = xdr.NewOperationBody(xdr.OperationTypeCreatePassiveOffer, m.PO)
o.TX.Operations = append(o.TX.Operations, m.O)
} else {
m.O.Body, m.Err = xdr.NewOperationBody(xdr.OperationTypeManageOffer, m.MO)
o.TX.Operations = append(o.TX.Operations, m.O)
}
return m.Err
}
开发者ID:FihlaTV,项目名称:bridge-server,代码行数:17,代码来源:transaction.go
示例2: GetSigned
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 ""
}
开发者ID:zzj882,项目名称:go-StellarWallet,代码行数:35,代码来源:stellar_account_merge.go
示例3: ExampleLowLevelTransaction
// ExampleLowLevelTransaction creates and signs a simple transaction, and then
// encodes it into a hex string capable of being submitted to stellar-core.
//
// It uses the low-level xdr facilities to create the transaction.
func ExampleLowLevelTransaction() {
spub, spriv, err := GenerateKeyFromSeed("SA26PHIKZM6CXDGR472SSGUQQRYXM6S437ZNHZGRM6QA4FOPLLLFRGDX")
if err != nil {
panic(err)
}
dpub, _, err := GenerateKeyFromSeed("SBQHO2IMYKXAYJFCWGXC7YKLJD2EGDPSK3IUDHVJ6OOTTKLSCK6Z6POM")
if err != nil {
panic(err)
}
asset, err := xdr.NewAsset(xdr.AssetTypeAssetTypeNative, nil)
if err != nil {
panic(err)
}
destination, err := AddressToAccountId(dpub.Address())
if err != nil {
panic(err)
}
op := xdr.PaymentOp{
Destination: destination,
Asset: asset,
Amount: 50 * 10000000,
}
memo, err := xdr.NewMemo(xdr.MemoTypeMemoNone, nil)
source, err := AddressToAccountId(spub.Address())
if err != nil {
panic(err)
}
body, err := xdr.NewOperationBody(xdr.OperationTypePayment, op)
if err != nil {
panic(err)
}
tx := xdr.Transaction{
SourceAccount: source,
Fee: 10,
SeqNum: xdr.SequenceNumber(1),
Memo: memo,
Operations: []xdr.Operation{
{Body: body},
},
}
var txBytes bytes.Buffer
_, err = xdr.Marshal(&txBytes, tx)
if err != nil {
panic(err)
}
txHash := Hash(txBytes.Bytes())
signature := spriv.Sign(txHash[:])
ds := xdr.DecoratedSignature{
Hint: spriv.Hint(),
Signature: xdr.Signature(signature[:]),
}
txe := xdr.TransactionEnvelope{
Tx: tx,
Signatures: []xdr.DecoratedSignature{ds},
}
var txeBytes bytes.Buffer
_, err = xdr.Marshal(&txeBytes, txe)
if err != nil {
panic(err)
}
txeB64 := base64.StdEncoding.EncodeToString(txeBytes.Bytes())
fmt.Printf("tx base64: %s", txeB64)
// Output: tx base64: AAAAAAU08yUQ8sHqhY8j9mXWwERfHC/3cKFSe/spAr0rGtO2AAAACgAAAAAAAAABAAAAAAAAAAAAAAABAAAAAAAAAAEAAAAA+fnTe7/v4whpBUx96oj92jfZPz7S00l3O2xeyeqWIA0AAAAAAAAAAB3NZQAAAAAAAAAAATXnnQoAAABAieruUIGcQH6RlQ+prYflPFU3nED2NvWhtaC+tgnKsqgiKURK4xo/W7EgH0+I6aQok52awbE+ksOxEQ5MLJ9eAw==
}
开发者ID:lackac,项目名称:horizon,代码行数:84,代码来源:transaction_test.go
注:本文中的github.com/stellar/go-stellar-base/xdr.NewOperationBody函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论