mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-11-24 14:35:53 +00:00
Add failed broadcast transactions on send error`
This commit is contained in:
parent
89c932dec1
commit
af93d5fdfe
@ -8,6 +8,7 @@ import (
|
|||||||
|
|
||||||
"github.com/kaspanet/kaspad/cmd/kaspawallet/daemon/client"
|
"github.com/kaspanet/kaspad/cmd/kaspawallet/daemon/client"
|
||||||
"github.com/kaspanet/kaspad/cmd/kaspawallet/daemon/pb"
|
"github.com/kaspanet/kaspad/cmd/kaspawallet/daemon/pb"
|
||||||
|
"github.com/kaspanet/kaspad/cmd/kaspawallet/daemon/server"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -37,7 +38,7 @@ func broadcast(conf *broadcastConfig) error {
|
|||||||
transactionsHex = strings.TrimSpace(string(transactionHexBytes))
|
transactionsHex = strings.TrimSpace(string(transactionHexBytes))
|
||||||
}
|
}
|
||||||
|
|
||||||
transactions, err := decodeTransactionsFromHex(transactionsHex)
|
transactions, err := server.DecodeTransactionsFromHex(transactionsHex)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,6 +8,7 @@ import (
|
|||||||
|
|
||||||
"github.com/kaspanet/kaspad/cmd/kaspawallet/daemon/client"
|
"github.com/kaspanet/kaspad/cmd/kaspawallet/daemon/client"
|
||||||
"github.com/kaspanet/kaspad/cmd/kaspawallet/daemon/pb"
|
"github.com/kaspanet/kaspad/cmd/kaspawallet/daemon/pb"
|
||||||
|
"github.com/kaspanet/kaspad/cmd/kaspawallet/daemon/server"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -37,7 +38,7 @@ func broadcastReplacement(conf *broadcastConfig) error {
|
|||||||
transactionsHex = strings.TrimSpace(string(transactionHexBytes))
|
transactionsHex = strings.TrimSpace(string(transactionHexBytes))
|
||||||
}
|
}
|
||||||
|
|
||||||
transactions, err := decodeTransactionsFromHex(transactionsHex)
|
transactions, err := server.DecodeTransactionsFromHex(transactionsHex)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,6 +7,7 @@ import (
|
|||||||
|
|
||||||
"github.com/kaspanet/kaspad/cmd/kaspawallet/daemon/client"
|
"github.com/kaspanet/kaspad/cmd/kaspawallet/daemon/client"
|
||||||
"github.com/kaspanet/kaspad/cmd/kaspawallet/daemon/pb"
|
"github.com/kaspanet/kaspad/cmd/kaspawallet/daemon/pb"
|
||||||
|
"github.com/kaspanet/kaspad/cmd/kaspawallet/daemon/server"
|
||||||
)
|
)
|
||||||
|
|
||||||
func bumpFeeUnsigned(conf *bumpFeeUnsignedConfig) error {
|
func bumpFeeUnsigned(conf *bumpFeeUnsignedConfig) error {
|
||||||
@ -51,7 +52,7 @@ func bumpFeeUnsigned(conf *bumpFeeUnsignedConfig) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fmt.Fprintln(os.Stderr, "Created unsigned transaction")
|
fmt.Fprintln(os.Stderr, "Created unsigned transaction")
|
||||||
fmt.Println(encodeTransactionsToHex(response.Transactions))
|
fmt.Println(server.EncodeTransactionsToHex(response.Transactions))
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,6 +7,7 @@ import (
|
|||||||
|
|
||||||
"github.com/kaspanet/kaspad/cmd/kaspawallet/daemon/client"
|
"github.com/kaspanet/kaspad/cmd/kaspawallet/daemon/client"
|
||||||
"github.com/kaspanet/kaspad/cmd/kaspawallet/daemon/pb"
|
"github.com/kaspanet/kaspad/cmd/kaspawallet/daemon/pb"
|
||||||
|
"github.com/kaspanet/kaspad/cmd/kaspawallet/daemon/server"
|
||||||
"github.com/kaspanet/kaspad/cmd/kaspawallet/utils"
|
"github.com/kaspanet/kaspad/cmd/kaspawallet/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -59,7 +60,7 @@ func createUnsignedTransaction(conf *createUnsignedTransactionConfig) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fmt.Fprintln(os.Stderr, "Created unsigned transaction")
|
fmt.Fprintln(os.Stderr, "Created unsigned transaction")
|
||||||
fmt.Println(encodeTransactionsToHex(response.UnsignedTransactions))
|
fmt.Println(server.EncodeTransactionsToHex(response.UnsignedTransactions))
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,6 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/kaspanet/kaspad/cmd/kaspawallet/daemon/pb"
|
"github.com/kaspanet/kaspad/cmd/kaspawallet/daemon/pb"
|
||||||
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (s *server) Send(_ context.Context, request *pb.SendRequest) (*pb.SendResponse, error) {
|
func (s *server) Send(_ context.Context, request *pb.SendRequest) (*pb.SendResponse, error) {
|
||||||
@ -24,7 +25,7 @@ func (s *server) Send(_ context.Context, request *pb.SendRequest) (*pb.SendRespo
|
|||||||
|
|
||||||
txIDs, err := s.broadcast(signedTransactions, false)
|
txIDs, err := s.broadcast(signedTransactions, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, errors.Wrapf(err, "error broadcasting transactions %s", EncodeTransactionsToHex(signedTransactions))
|
||||||
}
|
}
|
||||||
|
|
||||||
return &pb.SendResponse{TxIDs: txIDs, SignedTransactions: signedTransactions}, nil
|
return &pb.SendResponse{TxIDs: txIDs, SignedTransactions: signedTransactions}, nil
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
package main
|
package server
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
@ -9,7 +9,7 @@ import (
|
|||||||
// We use a separator that is not in the hex alphabet, but which will not split selection with a double click
|
// We use a separator that is not in the hex alphabet, but which will not split selection with a double click
|
||||||
const hexTransactionsSeparator = "_"
|
const hexTransactionsSeparator = "_"
|
||||||
|
|
||||||
func encodeTransactionsToHex(transactions [][]byte) string {
|
func EncodeTransactionsToHex(transactions [][]byte) string {
|
||||||
transactionsInHex := make([]string, len(transactions))
|
transactionsInHex := make([]string, len(transactions))
|
||||||
for i, transaction := range transactions {
|
for i, transaction := range transactions {
|
||||||
transactionsInHex[i] = hex.EncodeToString(transaction)
|
transactionsInHex[i] = hex.EncodeToString(transaction)
|
||||||
@ -17,7 +17,7 @@ func encodeTransactionsToHex(transactions [][]byte) string {
|
|||||||
return strings.Join(transactionsInHex, hexTransactionsSeparator)
|
return strings.Join(transactionsInHex, hexTransactionsSeparator)
|
||||||
}
|
}
|
||||||
|
|
||||||
func decodeTransactionsFromHex(transactionsHex string) ([][]byte, error) {
|
func DecodeTransactionsFromHex(transactionsHex string) ([][]byte, error) {
|
||||||
splitTransactionsHexes := strings.Split(transactionsHex, hexTransactionsSeparator)
|
splitTransactionsHexes := strings.Split(transactionsHex, hexTransactionsSeparator)
|
||||||
transactions := make([][]byte, len(splitTransactionsHexes))
|
transactions := make([][]byte, len(splitTransactionsHexes))
|
||||||
|
|
||||||
@ -38,7 +38,7 @@ func parse(conf *parseConfig) error {
|
|||||||
transactionHex = strings.TrimSpace(string(transactionHexBytes))
|
transactionHex = strings.TrimSpace(string(transactionHexBytes))
|
||||||
}
|
}
|
||||||
|
|
||||||
transactions, err := decodeTransactionsFromHex(transactionHex)
|
transactions, err := server.DecodeTransactionsFromHex(transactionHex)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,6 +6,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/kaspanet/kaspad/cmd/kaspawallet/daemon/server"
|
||||||
"github.com/kaspanet/kaspad/cmd/kaspawallet/keys"
|
"github.com/kaspanet/kaspad/cmd/kaspawallet/keys"
|
||||||
"github.com/kaspanet/kaspad/cmd/kaspawallet/libkaspawallet"
|
"github.com/kaspanet/kaspad/cmd/kaspawallet/libkaspawallet"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
@ -40,7 +41,7 @@ func sign(conf *signConfig) error {
|
|||||||
}
|
}
|
||||||
transactionsHex = strings.TrimSpace(string(transactionHexBytes))
|
transactionsHex = strings.TrimSpace(string(transactionHexBytes))
|
||||||
}
|
}
|
||||||
partiallySignedTransactions, err := decodeTransactionsFromHex(transactionsHex)
|
partiallySignedTransactions, err := server.DecodeTransactionsFromHex(transactionsHex)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -72,6 +73,6 @@ func sign(conf *signConfig) error {
|
|||||||
fmt.Fprintln(os.Stderr, "Successfully signed transaction")
|
fmt.Fprintln(os.Stderr, "Successfully signed transaction")
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println(encodeTransactionsToHex(updatedPartiallySignedTransactions))
|
fmt.Println(server.EncodeTransactionsToHex(updatedPartiallySignedTransactions))
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user