func setAccountId(addressOrSeed string, aid *xdr.AccountId) error { kp, err := keypair.Parse(addressOrSeed) if err != nil { return err } return aid.SetAddress(kp.Address()) }
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()) }
// Add writes an effect to the database while automatically tracking the index // to use. func (ei *EffectIngestion) Add(aid xdr.AccountId, typ history.EffectType, details interface{}) bool { if ei.err != nil { return false } ei.added++ var haid int64 haid, ei.err = ei.Accounts.Get(aid.Address()) if ei.err != nil { return false } ei.err = ei.Dest.Effect(haid, ei.OperationID, ei.added, typ, details) if ei.err != nil { return false } return true }
func (is *Session) tradeDetails(buyer, seller xdr.AccountId, claim xdr.ClaimOfferAtom) (bd map[string]interface{}, sd map[string]interface{}) { bd = map[string]interface{}{ "offer_id": claim.OfferId, "seller": seller.Address(), "bought_amount": amount.String(claim.AmountSold), "sold_amount": amount.String(claim.AmountBought), } is.assetDetails(bd, claim.AssetSold, "bought_") is.assetDetails(bd, claim.AssetBought, "sold_") sd = map[string]interface{}{ "offer_id": claim.OfferId, "seller": buyer.Address(), "bought_amount": amount.String(claim.AmountBought), "sold_amount": amount.String(claim.AmountSold), } is.assetDetails(sd, claim.AssetBought, "bought_") is.assetDetails(sd, claim.AssetSold, "sold_") return }
// Operation ingests the provided operation data into a new row in the // `history_operations` table func (ingest *Ingestion) Operation( id int64, txid int64, order int32, source xdr.AccountId, typ xdr.OperationType, details map[string]interface{}, ) error { djson, err := json.Marshal(details) if err != nil { return err } sql := ingest.operations.Values(id, txid, order, source.Address(), typ, djson) _, err = ingest.DB.Exec(sql) if err != nil { return err } return nil }
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()) }) }) }) })
"AAAAAgAAAAMAAAABAAAAAAAAAABi/B0L0JGythwN1lY0aypo19NHxvLCyO5tBEcCVvwF9w3gtrOnZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAEAAAACAAAAAAAAAABi/B0L0JGythwN1lY0aypo19NHxvLCyO5tBEcCVvwF9w3gtrOnY/+cAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAA==", "AAAAAAAAAAEAAAACAAAAAAAAAAIAAAAAAAAAAK6jei3jmoI8TGlD/egc37PXtHKKzWV8wViZBaCu5L5MAAAAADuaygAAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAIAAAAAAAAAAGL8HQvQkbK2HA3WVjRrKmjX00fG8sLI7m0ERwJW/AX3DeC2s2vJNNQAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAA", ) var removeTrustline = bundle( "AAAAAgAAAAMAAAAEAAAAAAAAAACuo3ot45qCPExpQ/3oHN+z17Ryis1lfMFYmQWgruS+TAAAAAJUC+M4AAAAAgAAAAIAAAABAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAEAAAAFAAAAAAAAAACuo3ot45qCPExpQ/3oHN+z17Ryis1lfMFYmQWgruS+TAAAAAJUC+LUAAAAAgAAAAMAAAABAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAA==", "AAAAAAAAAAEAAAADAAAAAQAAAAUAAAAAAAAAAK6jei3jmoI8TGlD/egc37PXtHKKzWV8wViZBaCu5L5MAAAAAlQL4tQAAAACAAAAAwAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAQAAAABAAAAAK6jei3jmoI8TGlD/egc37PXtHKKzWV8wViZBaCu5L5MAAAAAVVTRAAAAAAAtbgXR6E7oDL0LQ+wYSC9zXvXVT3xiPiYuSb1DvmQLe8AAAAAAAAAAAAAAAlQL5AAAAAAAQAAAAAAAAAAAAAAAgAAAAEAAAAArqN6LeOagjxMaUP96Bzfs9e0corNZXzBWJkFoK7kvkwAAAABVVNEAAAAAAC1uBdHoTugMvQtD7BhIL3Ne9dVPfGI+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()) })