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

* Allow to send --all * Fix a typo --------- Co-authored-by: Ori Newman <orinewman1@gmail.com>
40 lines
1.1 KiB
Go
40 lines
1.1 KiB
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"os"
|
|
|
|
"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,
|
|
IsSendAll: conf.IsSendAll,
|
|
UseExistingChangeAddress: conf.UseExistingChangeAddress,
|
|
})
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
fmt.Fprintln(os.Stderr, "Created unsigned transaction")
|
|
fmt.Println(encodeTransactionsToHex(response.UnsignedTransactions))
|
|
|
|
return nil
|
|
}
|