diff --git a/cmd/ocean/transaction.go b/cmd/ocean/transaction.go index ea3c195..38839dc 100644 --- a/cmd/ocean/transaction.go +++ b/cmd/ocean/transaction.go @@ -6,6 +6,7 @@ import ( "fmt" "math" + "github.com/shopspring/decimal" "github.com/spf13/cobra" pb "github.com/vulpemventures/ocean/api-spec/protobuf/gen/go/ocean/v1" ) @@ -153,9 +154,11 @@ type output struct { } func (o output) proto() *pb.Output { + btc := decimal.NewFromFloat(math.Pow10(8)) + amount := decimal.NewFromFloat(o.Amount).Mul(btc).BigInt().Uint64() return &pb.Output{ Address: o.Address, - Amount: uint64(o.Amount * math.Pow10(8)), + Amount: amount, Asset: o.Asset, } } diff --git a/go.mod b/go.mod index c3d6695..640f632 100644 --- a/go.mod +++ b/go.mod @@ -30,6 +30,7 @@ require ( require ( github.com/jackc/pgconn v1.12.1 github.com/jackc/pgx/v4 v4.16.1 + github.com/shopspring/decimal v1.2.0 github.com/tyler-smith/go-bip39 v1.1.0 github.com/vulpemventures/go-bip32 v0.0.0-20200624192635-867c159da4d7 )