Skip to content

Commit

Permalink
Compare wallet addresses by value
Browse files Browse the repository at this point in the history
  • Loading branch information
someone235 committed Dec 27, 2023
1 parent 0534413 commit 4570be9
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions cmd/kaspawallet/daemon/server/create_unsigned_transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"github.com/kaspanet/kaspad/domain/consensus/utils/constants"
"github.com/kaspanet/kaspad/util"
"github.com/pkg/errors"
"golang.org/x/exp/slices"
)

// TODO: Implement a better fee estimation mechanism
Expand Down Expand Up @@ -105,7 +104,7 @@ func (s *server) selectUTXOs(spendAmount uint64, isSendAll bool, feePerInput uin
}

for _, utxo := range s.utxosSortedByAmount {
if (fromAddresses != nil && !slices.Contains(fromAddresses, utxo.address)) ||
if (fromAddresses != nil && !walletAddressesContains(fromAddresses, utxo.address)) ||
!isUTXOSpendable(utxo, dagInfo.VirtualDAAScore, coinbaseMaturity) {
continue
}
Expand Down Expand Up @@ -153,3 +152,13 @@ func (s *server) selectUTXOs(spendAmount uint64, isSendAll bool, feePerInput uin

return selectedUTXOs, totalReceived, totalValue - totalSpend, nil
}

func walletAddressesContains(addresses []*walletAddress, contains *walletAddress) bool {
for _, address := range addresses {
if *address == *contains {
return true
}
}

return false
}

0 comments on commit 4570be9

Please sign in to comment.