OSDN Git Service

module claim
[bytom/vapor.git] / api / main_transact.go
1 package api
2
3 import (
4         "github.com/vapor/claim/rpc"
5         maintx "github.com/vapor/claim/rpc/bytom"
6         chainjson "github.com/vapor/encoding/json"
7 )
8
9 type mainTxResp struct {
10         Tx chainjson.HexBytes `json:"tx"`
11 }
12
13 func (a *API) buildMainChainTxForContract(ins rpc.MainTxParam) Response {
14         main := &maintx.BytomMainTx{
15                 MainTxParam: ins,
16         }
17
18         resp, err := main.BuildMainChainTxForContract()
19         if err != nil {
20                 return NewErrorResponse(err)
21         }
22
23         return NewSuccessResponse(&mainTxResp{Tx: resp})
24 }
25
26 func (a *API) buildMainChainTx(ins rpc.MainTxParam) Response {
27         main := &maintx.BytomMainTx{
28                 MainTxParam: ins,
29         }
30
31         resp, err := main.BuildMainChainTx()
32         if err != nil {
33                 return NewErrorResponse(err)
34         }
35
36         return NewSuccessResponse(&mainTxResp{Tx: resp})
37 }
38
39 func (a *API) signWithKey(ins rpc.MainTxSignParam) Response {
40         sign := maintx.BytomMainSign{
41                 MainTxSignParam: ins,
42         }
43
44         resp, err := sign.SignWithKey()
45         if err != nil {
46                 return NewErrorResponse(err)
47         }
48         return NewSuccessResponse(resp)
49 }