Skip to content

Commit

Permalink
Fix amount conversion from btc to sats unit (#81)
Browse files Browse the repository at this point in the history
* Fix amount conversion from btc to sats unit

* Remove dev logs
  • Loading branch information
altafan authored Feb 1, 2024
1 parent 8f3f6d2 commit b21c38e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 4 additions & 1 deletion cmd/ocean/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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,
}
}
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down

0 comments on commit b21c38e

Please sign in to comment.