本文整理汇总了Golang中github.com/stellar/go/xdr.AccountId类的典型用法代码示例。如果您正苦于以下问题:Golang AccountId类的具体用法?Golang AccountId怎么用?Golang AccountId使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AccountId类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: setAccountId
func setAccountId(addressOrSeed string, aid *xdr.AccountId) error {
kp, err := keypair.Parse(addressOrSeed)
if err != nil {
return err
}
if aid == nil {
return errors.New("aid is nil in setAccountId")
}
return aid.SetAddress(kp.Address())
}
开发者ID:stellar,项目名称:bridge-server,代码行数:12,代码来源:util.go
示例2:
address = "GAXEMCEXBERNSRXOEKD4JAIKVECIXQCENHEBRVSPX2TTYZPMNEDSQCNQ"
bad = "foo"
)
JustBeforeEach(func() {
subject = ManageDataBuilder{}
subject.Mutate(mut)
})
Describe("SourceAccount", func() {
Context("using a valid stellar address", func() {
BeforeEach(func() { mut = SourceAccount{address} })
It("succeeds", func() {
Expect(subject.Err).NotTo(HaveOccurred())
})
It("sets the destination to the correct xdr.AccountId", func() {
var aid xdr.AccountId
aid.SetAddress(address)
Expect(subject.O.SourceAccount.MustEd25519()).To(Equal(aid.MustEd25519()))
})
})
Context("using an invalid value", func() {
BeforeEach(func() { mut = SourceAccount{bad} })
It("failed", func() { Expect(subject.Err).To(HaveOccurred()) })
})
})
})
开发者ID:stellar,项目名称:bridge-server,代码行数:30,代码来源:manage_data_test.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() {
skp := keypair.MustParse("SA26PHIKZM6CXDGR472SSGUQQRYXM6S437ZNHZGRM6QA4FOPLLLFRGDX")
dkp := keypair.MustParse("SBQHO2IMYKXAYJFCWGXC7YKLJD2EGDPSK3IUDHVJ6OOTTKLSCK6Z6POM")
asset, err := xdr.NewAsset(xdr.AssetTypeAssetTypeNative, nil)
if err != nil {
panic(err)
}
var destination xdr.AccountId
err = destination.SetAddress(dkp.Address())
if err != nil {
panic(err)
}
op := xdr.PaymentOp{
Destination: destination,
Asset: asset,
Amount: 50 * 10000000,
}
memo, err := xdr.NewMemo(xdr.MemoTypeMemoNone, nil)
var source xdr.AccountId
err = source.SetAddress(skp.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.Hash(txBytes.Bytes())
signature, err := skp.Sign(txHash[:])
if err != nil {
panic(err)
}
ds := xdr.DecoratedSignature{
Hint: skp.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/v4whpBUx96oj92jfZPz7S00l3O2xeyeqWIA0AAAAAAAAAAB3NZQAAAAAAAAAAASsa07YAAABAieruUIGcQH6RlQ+prYflPFU3nED2NvWhtaC+tgnKsqgiKURK4xo/W7EgH0+I6aQok52awbE+ksOxEQ5MLJ9eAw==
}
开发者ID:stellar,项目名称:bridge-server,代码行数:80,代码来源:main_test.go
示例4:
"AAAAAgAAAAMAAAABAAAAAAAA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AAAAAAAAAAAAAlQL5AAAAAAAQAAAAAAAAAAAAAAAgAAAAEAAAAArqN6LeOagjxMaUP96Bzfs9e0corNZXzBWJkFoK7kvkwAAAABVVNEAAAAAAC1uBdHoTugMvQtD7BhIL3Ne9dVPfGI+Ji5JvUO+ZAt7w==",
)
var updateTrustline = bundle(
"AAAAAgAAAAMAAAADAAAAAAAAAACuo3ot45qCPExpQ/3oHN+z17Ryis1lfMFYmQWgruS+TAAAAAJUC+OcAAAAAgAAAAEAAAABAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAEAAAAEAAAAAAAAAACuo3ot45qCPExpQ/3oHN+z17Ryis1lfMFYmQWgruS+TAAAAAJUC+M4AAAAAgAAAAIAAAABAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAA==",
"AAAAAAAAAAEAAAACAAAAAwAAAAMAAAABAAAAAK6jei3jmoI8TGlD/egc37PXtHKKzWV8wViZBaCu5L5MAAAAAVVTRAAAAAAAtbgXR6E7oDL0LQ+wYSC9zXvXVT3xiPiYuSb1DvmQLe8AAAAAAAAAAH//////////AAAAAQAAAAAAAAAAAAAAAQAAAAQAAAABAAAAAK6jei3jmoI8TGlD/egc37PXtHKKzWV8wViZBaCu5L5MAAAAAVVTRAAAAAAAtbgXR6E7oDL0LQ+wYSC9zXvXVT3xiPiYuSb1DvmQLe8AAAAAAAAAAAAAAAlQL5AAAAAAAQAAAAAAAAAA",
)
// var mergeAccount = nil //TODO
var newAccount xdr.AccountId
var masterAccount xdr.AccountId
var nonexistantAccount xdr.AccountId
var gatewayAccount xdr.AccountId
BeforeEach(func() {
err := newAccount.SetAddress("GCXKG6RN4ONIEPCMNFB732A436Z5PNDSRLGWK7GBLCMQLIFO4S7EYWVU")
Expect(err).ToNot(HaveOccurred())
err = masterAccount.SetAddress("GBRPYHIL2CI3FNQ4BXLFMNDLFJUNPU2HY3ZMFSHONUCEOASW7QC7OX2H")
Expect(err).ToNot(HaveOccurred())
err = nonexistantAccount.SetAddress("GDGAWQZT2RALG2XBEESTMA7PHDASK4EZGXWGBCIHZRSGGLZOGZGV5JL3")
Expect(err).ToNot(HaveOccurred())
err = gatewayAccount.SetAddress("GC23QF2HUE52AMXUFUH3AYJAXXGXXV2VHXYYR6EYXETPKDXZSAW67XO4")
Expect(err).ToNot(HaveOccurred())
})
开发者ID:stellar,项目名称:bridge-server,代码行数:30,代码来源:bundle_test.go
示例5:
JustBeforeEach(func() {
subject = ManageOfferBuilder{}
subject.Mutate(mut)
})
Describe("CreateOffer", func() {
Context("creates offer properly", func() {
It("sets values properly", func() {
builder := CreateOffer(rate, "20")
Expect(builder.MO.Amount).To(Equal(xdr.Int64(200000000)))
Expect(builder.MO.Selling.Type).To(Equal(xdr.AssetTypeAssetTypeCreditAlphanum4))
Expect(builder.MO.Selling.AlphaNum4.AssetCode).To(Equal([4]byte{'E', 'U', 'R', 0}))
var aid xdr.AccountId
aid.SetAddress(rate.Selling.Issuer)
Expect(builder.MO.Selling.AlphaNum4.Issuer.MustEd25519()).To(Equal(aid.MustEd25519()))
Expect(builder.MO.Selling.AlphaNum12).To(BeNil())
Expect(builder.MO.Buying.Type).To(Equal(xdr.AssetTypeAssetTypeNative))
Expect(builder.MO.Buying.AlphaNum4).To(BeNil())
Expect(builder.MO.Buying.AlphaNum12).To(BeNil())
Expect(builder.MO.Price.N).To(Equal(xdr.Int32(8253)))
Expect(builder.MO.Price.D).To(Equal(xdr.Int32(200)))
Expect(builder.MO.OfferId).To(Equal(xdr.Uint64(0)))
})
})
})
开发者ID:stellar,项目名称:bridge-server,代码行数:30,代码来源:manage_offer_test.go
示例6:
JustBeforeEach(func() {
subject = SetOptionsBuilder{}
subject.Mutate(mut)
})
Describe("InflationDest", func() {
Context("using a valid stellar address", func() {
BeforeEach(func() { mut = InflationDest(address) })
It("succeeds", func() {
Expect(subject.Err).NotTo(HaveOccurred())
})
It("sets the destination to the correct xdr.AccountId", func() {
var aid xdr.AccountId
aid.SetAddress(address)
Expect(subject.SO.InflationDest.MustEd25519()).To(Equal(aid.MustEd25519()))
})
})
Context("using an invalid value", func() {
BeforeEach(func() { mut = InflationDest(bad) })
It("failed", func() { Expect(subject.Err).To(HaveOccurred()) })
})
})
Describe("Signer", func() {
Context("using a valid stellar address", func() {
BeforeEach(func() { mut = Signer{address, 5} })
开发者ID:stellar,项目名称:bridge-server,代码行数:29,代码来源:set_options_test.go
示例7:
JustBeforeEach(func() {
subject = AccountMergeBuilder{}
subject.Mutate(mut)
})
Describe("Destination", func() {
Context("using a valid stellar address", func() {
BeforeEach(func() { mut = Destination{address} })
It("succeeds", func() {
Expect(subject.Err).NotTo(HaveOccurred())
})
It("sets the destination to the correct xdr.AccountId", func() {
var aid xdr.AccountId
aid.SetAddress(address)
Expect(subject.Destination.Equals(aid)).To(BeTrue())
})
})
Context("using an invalid value", func() {
BeforeEach(func() { mut = Destination{bad} })
It("failed", func() { Expect(subject.Err).To(HaveOccurred()) })
})
})
Describe("SourceAccount", func() {
Context("using a valid stellar address", func() {
BeforeEach(func() { mut = SourceAccount{address} })
开发者ID:stellar,项目名称:bridge-server,代码行数:29,代码来源:account_merge_test.go
示例8:
Describe("Payment", func() {
JustBeforeEach(func() {
subject = PaymentBuilder{}
subject.Mutate(mut)
})
Describe("CreditAmount", func() {
Context("AlphaNum4", func() {
BeforeEach(func() {
mut = CreditAmount{"USD", address, "50.0"}
})
It("sets the asset properly", func() {
Expect(subject.P.Amount).To(Equal(xdr.Int64(500000000)))
Expect(subject.P.Asset.Type).To(Equal(xdr.AssetTypeAssetTypeCreditAlphanum4))
Expect(subject.P.Asset.AlphaNum4.AssetCode).To(Equal([4]byte{'U', 'S', 'D', 0}))
var aid xdr.AccountId
aid.SetAddress(address)
Expect(subject.P.Asset.AlphaNum4.Issuer.MustEd25519()).To(Equal(aid.MustEd25519()))
Expect(subject.P.Asset.AlphaNum12).To(BeNil())
})
It("succeeds", func() {
Expect(subject.Err).NotTo(HaveOccurred())
})
})
Context("AlphaNum12", func() {
BeforeEach(func() {
mut = CreditAmount{"ABCDEF", address, "50.0"}
})
It("sets the asset properly", func() {
Expect(subject.P.Amount).To(Equal(xdr.Int64(500000000)))
开发者ID:stellar,项目名称:bridge-server,代码行数:31,代码来源:payment_test.go
注:本文中的github.com/stellar/go/xdr.AccountId类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论