diff --git a/v2/accounting/accounting.go b/v2/accounting/accounting.go index a49f79b4..3aa24100 100644 --- a/v2/accounting/accounting.go +++ b/v2/accounting/accounting.go @@ -17,6 +17,12 @@ type BalanceRequest struct { verifyHeader *service.RequestVerificationHeader } +type Decimal struct { + val int64 + + prec uint32 +} + func (b *BalanceRequestBody) GetOwnerID() *refs.OwnerID { if b != nil { return b.ownerID @@ -88,3 +94,31 @@ func (b *BalanceRequest) SetRequestVerificationHeader(v *service.RequestVerifica b.verifyHeader = v } } + +func (d *Decimal) GetValue() int64 { + if d != nil { + return d.val + } + + return 0 +} + +func (d *Decimal) SetValue(v int64) { + if d != nil { + d.val = v + } +} + +func (d *Decimal) GetPrecision() uint32 { + if d != nil { + return d.prec + } + + return 0 +} + +func (d *Decimal) SetPrecision(v uint32) { + if d != nil { + d.prec = v + } +} diff --git a/v2/accounting/convert.go b/v2/accounting/convert.go index 74d96c55..8cc2936a 100644 --- a/v2/accounting/convert.go +++ b/v2/accounting/convert.go @@ -65,3 +65,29 @@ func BalanceRequestFromGRPCMessage(m *accounting.BalanceRequest) *BalanceRequest return b } + +func DecimalToGRPCMessage(d *Decimal) *accounting.Decimal { + if d == nil { + return nil + } + + m := new(accounting.Decimal) + + m.SetValue(d.GetValue()) + m.SetPrecision(d.GetPrecision()) + + return m +} + +func DecimalFromGRPCMessage(m *accounting.Decimal) *Decimal { + if m == nil { + return nil + } + + d := new(Decimal) + + d.SetValue(m.GetValue()) + d.SetPrecision(m.GetPrecision()) + + return d +}