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>
58 lines
1.5 KiB
Go
58 lines
1.5 KiB
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"io/ioutil"
|
|
"strings"
|
|
|
|
"github.com/kaspanet/kaspad/cmd/kaspawallet/daemon/client"
|
|
"github.com/kaspanet/kaspad/cmd/kaspawallet/daemon/pb"
|
|
"github.com/kaspanet/kaspad/cmd/kaspawallet/daemon/server"
|
|
"github.com/pkg/errors"
|
|
)
|
|
|
|
func broadcast(conf *broadcastConfig) error {
|
|
daemonClient, tearDown, err := client.Connect(conf.DaemonAddress)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
defer tearDown()
|
|
|
|
ctx, cancel := context.WithTimeout(context.Background(), daemonTimeout)
|
|
defer cancel()
|
|
|
|
if conf.Transactions == "" && conf.TransactionsFile == "" {
|
|
return errors.Errorf("Either --transaction or --transaction-file is required")
|
|
}
|
|
if conf.Transactions != "" && conf.TransactionsFile != "" {
|
|
return errors.Errorf("Both --transaction and --transaction-file cannot be passed at the same time")
|
|
}
|
|
|
|
transactionsHex := conf.Transactions
|
|
if conf.TransactionsFile != "" {
|
|
transactionHexBytes, err := ioutil.ReadFile(conf.TransactionsFile)
|
|
if err != nil {
|
|
return errors.Wrapf(err, "Could not read hex from %s", conf.TransactionsFile)
|
|
}
|
|
transactionsHex = strings.TrimSpace(string(transactionHexBytes))
|
|
}
|
|
|
|
transactions, err := server.DecodeTransactionsFromHex(transactionsHex)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
response, err := daemonClient.Broadcast(ctx, &pb.BroadcastRequest{Transactions: transactions})
|
|
if err != nil {
|
|
return err
|
|
}
|
|
fmt.Println("Transactions were sent successfully")
|
|
fmt.Println("Transaction ID(s): ")
|
|
for _, txID := range response.TxIDs {
|
|
fmt.Printf("\t%s\n", txID)
|
|
}
|
|
|
|
return nil
|
|
}
|