Skip to content

Commit

Permalink
mint: simplify AmountSplit by iterating over amount bits (#44)
Browse files Browse the repository at this point in the history
  • Loading branch information
gohumble committed May 1, 2023
1 parent 5a7f52a commit 6333ece
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions mint/mint.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ import (
"encoding/hex"
"fmt"
"math"
"math/bits"
"math/bits"
"reflect"
"strconv"
"strings"

"github.com/btcsuite/btcd/btcutil"
Expand Down Expand Up @@ -430,7 +429,7 @@ func AmountSplit(amount uint64) []uint64 {
rv := make([]uint64, 0)
for i := 0; i < bits.Len64(amount); i++ {
if (amount & (1 << i)) != 0 { // if bit i is set, add 2**i to list
rv = append(rv, 1 << i)
rv = append(rv, 1<<i)
}
}
return rv
Expand Down

0 comments on commit 6333ece

Please sign in to comment.