forked from stellar/go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclaim_claimable_balance_details.go
46 lines (36 loc) · 1.25 KB
/
claim_claimable_balance_details.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package ingest
import (
"fmt"
"github.com/stellar/go/xdr"
)
type ClaimClaimableBalanceDetail struct {
BalanceID string `json:"balance_id"`
Claimant string `json:"claimant"`
ClaimantMuxed string `json:"claimant_muxed"`
ClaimantMuxedID uint64 `json:"claimant_muxed_id"`
}
func (o *LedgerOperation) ClaimClaimableBalanceDetails() (ClaimClaimableBalanceDetail, error) {
op, ok := o.Operation.Body.GetClaimClaimableBalanceOp()
if !ok {
return ClaimClaimableBalanceDetail{}, fmt.Errorf("could not access ClaimClaimableBalance info for this operation (index %d)", o.OperationIndex)
}
claimClaimableBalanceDetail := ClaimClaimableBalanceDetail{
Claimant: o.SourceAccount(),
}
var err error
var balanceID string
balanceID, err = xdr.MarshalBase64(op.BalanceId)
if err != nil {
return ClaimClaimableBalanceDetail{}, err
}
claimClaimableBalanceDetail.BalanceID = balanceID
var claimantMuxed string
var claimantMuxedID uint64
claimantMuxed, claimantMuxedID, err = getMuxedAccountDetails(o.sourceAccountXDR())
if err != nil {
return ClaimClaimableBalanceDetail{}, err
}
claimClaimableBalanceDetail.ClaimantMuxed = claimantMuxed
claimClaimableBalanceDetail.ClaimantMuxedID = claimantMuxedID
return claimClaimableBalanceDetail, nil
}