forked from kaspanet/kaspad
-
Notifications
You must be signed in to change notification settings - Fork 2
/
send.go
31 lines (24 loc) · 860 Bytes
/
send.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
package server
import (
"context"
"github.com/Kash-Protocol/kashd/cmd/kashwallet/daemon/pb"
"github.com/Kash-Protocol/kashd/domain/consensus/model/externalapi"
)
func (s *server) Send(_ context.Context, request *pb.SendRequest) (*pb.SendResponse, error) {
s.lock.Lock()
defer s.lock.Unlock()
unsignedTransactions, err := s.createUnsignedTransactions(request.ToAddress, externalapi.AssetTypeFromUint32(request.AssetType),
request.Amount, request.IsSendAll, request.From, request.UseExistingChangeAddress)
if err != nil {
return nil, err
}
signedTransactions, err := s.signTransactions(unsignedTransactions, request.Password)
if err != nil {
return nil, err
}
txIDs, err := s.broadcast(signedTransactions, false)
if err != nil {
return nil, err
}
return &pb.SendResponse{TxIDs: txIDs, SignedTransactions: signedTransactions}, nil
}