mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-05-19 13:26:47 +00:00

* Added option to choose from address in kaspawallet + fixed a bug with 0 change * Checking if From is missing * Fixed after merge to kaspad0.12 * Applying changes also to send command * Better help description * Fixed bug where we take all utxos except the one we wanted * Swallow the parsing error only when we want to filter * checking for wallet address directly * go fmt * Changing to `--from-address` Co-authored-by: Ori Newman <orinewman1@gmail.com>
36 lines
935 B
Go
36 lines
935 B
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"github.com/kaspanet/kaspad/cmd/kaspawallet/daemon/client"
|
|
"github.com/kaspanet/kaspad/cmd/kaspawallet/daemon/pb"
|
|
"github.com/kaspanet/kaspad/domain/consensus/utils/constants"
|
|
)
|
|
|
|
func createUnsignedTransaction(conf *createUnsignedTransactionConfig) error {
|
|
daemonClient, tearDown, err := client.Connect(conf.DaemonAddress)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
defer tearDown()
|
|
|
|
ctx, cancel := context.WithTimeout(context.Background(), daemonTimeout)
|
|
defer cancel()
|
|
|
|
sendAmountSompi := uint64(conf.SendAmount * constants.SompiPerKaspa)
|
|
response, err := daemonClient.CreateUnsignedTransactions(ctx, &pb.CreateUnsignedTransactionsRequest{
|
|
From: conf.FromAddresses,
|
|
Address: conf.ToAddress,
|
|
Amount: sendAmountSompi,
|
|
})
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
fmt.Println("Created unsigned transaction")
|
|
fmt.Println(encodeTransactionsToHex(response.UnsignedTransactions))
|
|
return nil
|
|
}
|