Пример #1
0
// PaymentEntity returns a new random valid payment
func PaymentEntity() (result entity.Payment) {
	result.PagingToken = "1"
	result.To = AccountID()
	result.From = AccountID()
	result.Asset = entity.Asset{Type: "native"}
	result.Memo = entity.Memo{Type: "none"}
	result.Amount = entity.MustParseAmount("1.123")

	if err := result.Valid(); err != nil {
		panic(err)
	}

	return
}
Пример #2
0
func (p *payment) Entity() (ent entity.Payment, err error) {
	if p.Type == "create_account" {
		ent.From = entity.AccountID(p.Funder)
		ent.To = entity.AccountID(p.Account)
		ent.Asset.Type = "native"
		ent.Asset.Code = ""
		ent.Asset.Issuer = ""
		ent.Amount = entity.MustParseAmount(p.StartingBalance)
	} else {
		ent.From = entity.AccountID(p.From)
		ent.To = entity.AccountID(p.To)
		ent.Asset.Type = p.AssetType
		ent.Asset.Code = p.AssetCode
		ent.Asset.Issuer = p.AssetIssuer
		ent.Amount = entity.MustParseAmount(p.Amount)
	}

	ent.PagingToken = p.PagingToken
	ent.Memo.Type = p.Memo.Type
	ent.Memo.Value = p.Memo.Value

	return
}