mirror of
https://github.com/kaspanet/kaspad.git
synced 2026-02-26 21:23:15 +00:00
Compare commits
3 Commits
send-patch
...
v0.12.18-r
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
707b3a159e | ||
|
|
decbcd8233 | ||
|
|
2d25c3d7a3 |
@@ -196,9 +196,12 @@ func (s *server) selectUTXOsWithPreselected(preSelectedUTXOs []*walletUTXO, allo
|
||||
})
|
||||
|
||||
totalValue += utxo.UTXOEntry.Amount()
|
||||
estimatedRecipientValue := spendAmount
|
||||
if isSendAll {
|
||||
estimatedRecipientValue = totalValue
|
||||
}
|
||||
|
||||
// We're overestimating a bit by assuming that any transaction will have a change output
|
||||
fee, err = s.estimateFee(selectedUTXOs, feeRate, maxFee, true)
|
||||
fee, err = s.estimateFee(selectedUTXOs, feeRate, maxFee, estimatedRecipientValue)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -257,9 +260,9 @@ func (s *server) selectUTXOsWithPreselected(preSelectedUTXOs []*walletUTXO, allo
|
||||
return selectedUTXOs, totalReceived, totalValue - totalSpend, nil
|
||||
}
|
||||
|
||||
func (s *server) estimateFee(selectedUTXOs []*libkaspawallet.UTXO, feeRate float64, maxFee uint64, assumeChange bool) (uint64, error) {
|
||||
fakePubKey := [util.PublicKeySize]byte{}
|
||||
fakeAddr, err := util.NewAddressPublicKey(fakePubKey[:], s.params.Prefix)
|
||||
func (s *server) estimateFee(selectedUTXOs []*libkaspawallet.UTXO, feeRate float64, maxFee uint64, recipientValue uint64) (uint64, error) {
|
||||
fakePubKey := [util.PublicKeySizeECDSA]byte{}
|
||||
fakeAddr, err := util.NewAddressPublicKeyECDSA(fakePubKey[:], s.params.Prefix) // We assume the worst case where the recipient address is ECDSA. In this case the scriptPubKey will be the longest.
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
@@ -271,15 +274,15 @@ func (s *server) estimateFee(selectedUTXOs []*libkaspawallet.UTXO, feeRate float
|
||||
|
||||
// This is an approximation for the distribution of value between the recipient output and the change output.
|
||||
var mockPayments []*libkaspawallet.Payment
|
||||
if assumeChange {
|
||||
if totalValue > recipientValue {
|
||||
mockPayments = []*libkaspawallet.Payment{
|
||||
{
|
||||
Address: fakeAddr,
|
||||
Amount: totalValue * 99 / 100,
|
||||
Amount: recipientValue,
|
||||
},
|
||||
{
|
||||
Address: fakeAddr,
|
||||
Amount: totalValue / 100,
|
||||
Amount: totalValue - recipientValue, // We ignore the fee since we expect it to be insignificant in mass calculation.
|
||||
},
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -72,7 +72,7 @@ func (s *server) mergeTransaction(
|
||||
totalValue += output.Value
|
||||
}
|
||||
// We're overestimating a bit by assuming that any transaction will have a change output
|
||||
fee, err := s.estimateFee(utxos, feeRate, maxFee, true)
|
||||
fee, err := s.estimateFee(utxos, feeRate, maxFee, sentValue)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -253,7 +253,7 @@ func (s *server) createSplitTransaction(transaction *serialization.PartiallySign
|
||||
totalSompi += selectedUTXOs[i-startIndex].UTXOEntry.Amount()
|
||||
}
|
||||
if len(selectedUTXOs) != 0 {
|
||||
fee, err := s.estimateFee(selectedUTXOs, feeRate, maxFee, false)
|
||||
fee, err := s.estimateFee(selectedUTXOs, feeRate, maxFee, totalSompi)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -90,12 +90,13 @@ func parse(conf *parseConfig) error {
|
||||
fmt.Println()
|
||||
|
||||
fee := allInputSompi - allOutputSompi
|
||||
fmt.Printf("Fee:\t%d Sompi (%f KAS)\n\n", fee, float64(fee)/float64(constants.SompiPerKaspa))
|
||||
fmt.Printf("Fee:\t%d Sompi (%f KAS)\n", fee, float64(fee)/float64(constants.SompiPerKaspa))
|
||||
mass, err := server.EstimateMassAfterSignatures(partiallySignedTransaction, keysFile.ECDSA, keysFile.MinimumSignatures, txMassCalculator)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
fmt.Printf("Mass: %d grams\n", mass)
|
||||
feeRate := float64(fee) / float64(mass)
|
||||
fmt.Printf("Fee rate: %.2f Sompi/Gram\n", feeRate)
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ const (
|
||||
// appBuild is defined as a variable so it can be overridden during the build
|
||||
// process with '-ldflags "-X github.com/kaspanet/kaspad/version.appBuild=foo"' if needed.
|
||||
// It MUST only contain characters from validCharacters.
|
||||
var appBuild string = "rc6"
|
||||
var appBuild string = "rc7"
|
||||
|
||||
var version = "" // string used for memoization of version
|
||||
|
||||
|
||||
Reference in New Issue
Block a user