-
Notifications
You must be signed in to change notification settings - Fork 12
/
create_unsigned_tx.go
executable file
·39 lines (32 loc) · 1.16 KB
/
create_unsigned_tx.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package main
import (
"context"
"fmt"
"os"
"github.com/Nexellia-Network/nexelliad/cmd/nexelliawallet/daemon/client"
"github.com/Nexellia-Network/nexelliad/cmd/nexelliawallet/daemon/pb"
"github.com/Nexellia-Network/nexelliad/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
}