mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-03-30 15:08:33 +00:00

* Add fee estimation to wallet * Add fee rate to kaspawallet parse * Update go version * Get rid of golint * Add RBF support to wallet * Fix bump_fee UTXO lookup and fix wrong change address * impl storage mass as per KIP9 * Use CalculateTransactionOverallMass where needed * Some fixes * Minor typos * Fix test * update version * BroadcastRBF -> BroadcastReplacement * rc3 * align proto files to only use camel case (fixed on RK as well) * Rename to FeePolicy and add MaxFee option + todo * apply max fee constrains * increase minChangeTarget to 10kas * fmt * Some fixes * fix description: maximum -> minimum * put min feerate check in the correct location * Fix calculateFeeLimits nil handling * Add validations to CLI flags * Change to rc6 * Add checkTransactionFeeRate * Add failed broadcast transactions on send error` * Fix estimateFee change value * Estimate fee correctly for --send-all * On estimateFee always assume that the recipient has ECDSA address * remove patch version --------- Co-authored-by: Michael Sutton <msutton@cs.huji.ac.il>
45 lines
2.0 KiB
Go
45 lines
2.0 KiB
Go
package rpcclient
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"github.com/kaspanet/kaspad/app/appmessage"
|
|
)
|
|
|
|
// SubmitTransactionReplacement sends an RPC request respective to the function's name and returns the RPC server's response
|
|
func (c *RPCClient) SubmitTransactionReplacement(transaction *appmessage.RPCTransaction, transactionID string) (*appmessage.SubmitTransactionReplacementResponseMessage, error) {
|
|
err := c.rpcRouter.outgoingRoute().Enqueue(appmessage.NewSubmitTransactionReplacementRequestMessage(transaction))
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
for {
|
|
response, err := c.route(appmessage.CmdSubmitTransactionReplacementResponseMessage).DequeueWithTimeout(c.timeout)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
SubmitTransactionReplacementResponse := response.(*appmessage.SubmitTransactionReplacementResponseMessage)
|
|
// Match the response to the expected ID. If they are different it means we got an old response which we
|
|
// previously timed-out on, so we log and continue waiting for the correct current response.
|
|
if SubmitTransactionReplacementResponse.TransactionID != transactionID {
|
|
if SubmitTransactionReplacementResponse.Error != nil {
|
|
// A non-updated Kaspad might return an empty ID in the case of error, so in
|
|
// such a case we fallback to checking if the error contains the expected ID
|
|
if SubmitTransactionReplacementResponse.TransactionID != "" || !strings.Contains(SubmitTransactionReplacementResponse.Error.Message, transactionID) {
|
|
log.Warnf("SubmitTransactionReplacement: received an error response for previous request: %s", SubmitTransactionReplacementResponse.Error)
|
|
continue
|
|
}
|
|
|
|
} else {
|
|
log.Warnf("SubmitTransactionReplacement: received a successful response for previous request with ID %s",
|
|
SubmitTransactionReplacementResponse.TransactionID)
|
|
continue
|
|
}
|
|
}
|
|
if SubmitTransactionReplacementResponse.Error != nil {
|
|
return nil, c.convertRPCError(SubmitTransactionReplacementResponse.Error)
|
|
}
|
|
|
|
return SubmitTransactionReplacementResponse, nil
|
|
}
|
|
}
|