diff --git a/cmd/kaspawallet/broadcast.go b/cmd/kaspawallet/broadcast.go index 7eb3f421f..71318cf67 100644 --- a/cmd/kaspawallet/broadcast.go +++ b/cmd/kaspawallet/broadcast.go @@ -42,6 +42,15 @@ func broadcast(conf *broadcastConfig) error { return err } + err = broadcastInBatches(ctx, daemonClient, transactions) + if err != nil { + return err + } + + return nil +} + +func broadcastInBatches(ctx context.Context, daemonClient pb.KaspawalletdClient, transactions [][]byte) error { const batch = 50 position := 0 @@ -57,8 +66,10 @@ func broadcast(conf *broadcastConfig) error { if err != nil { return err } - if position == 0 { + if position == 0 && position+batch >= len(transactions) { fmt.Println("Transactions were sent successfully") + } else { + fmt.Println("Transaction batch was sent successfully") } fmt.Println("Transaction ID(s): ") for _, txID := range response.TxIDs { @@ -66,6 +77,5 @@ func broadcast(conf *broadcastConfig) error { } position += batch } - return nil } diff --git a/cmd/kaspawallet/send.go b/cmd/kaspawallet/send.go index 79f24c69a..fd71c2403 100644 --- a/cmd/kaspawallet/send.go +++ b/cmd/kaspawallet/send.go @@ -64,15 +64,10 @@ func send(conf *sendConfig) error { fmt.Printf("Broadcasting %d transactions\n", len(signedTransactions)) } - response, err := daemonClient.Broadcast(ctx, &pb.BroadcastRequest{Transactions: signedTransactions}) + err = broadcastInBatches(ctx, daemonClient, signedTransactions) 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 }