forked from kaspanet/kaspad
-
Notifications
You must be signed in to change notification settings - Fork 7
/
create_unsigned_tx.go
44 lines (35 loc) · 1.09 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
40
41
42
43
44
package main
import (
"context"
"fmt"
"os"
"github.com/Hoosat-Oy/HTND/cmd/htnwallet/daemon/client"
"github.com/Hoosat-Oy/HTND/cmd/htnwallet/daemon/pb"
"github.com/Hoosat-Oy/HTND/cmd/htnwallet/utils"
)
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, err := utils.KasToSompi(conf.SendAmount)
if err != nil {
return err
}
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
}