6 "github.com/vapor/blockchain/txbuilder"
7 "github.com/vapor/claim/rpc"
8 chainjson "github.com/vapor/encoding/json"
11 func (a *API) createAccountReceiver(ctx context.Context, ins struct {
12 AccountID string `json:"account_id"`
13 AccountAlias string `json:"account_alias"`
15 accountID := ins.AccountID
16 if ins.AccountAlias != "" {
17 account, err := a.wallet.AccountMgr.FindByAlias(ins.AccountAlias)
19 return NewErrorResponse(err)
22 accountID = account.ID
25 program, err := a.wallet.AccountMgr.CreateAddress(accountID, false)
27 return NewErrorResponse(err)
30 return NewSuccessResponse(&txbuilder.Receiver{
31 ControlProgram: program.ControlProgram,
32 Address: program.Address,
36 type fundingResp struct {
37 MainchainAddress string `json:"mainchain_address"`
38 ControlProgram chainjson.HexBytes `json:"control_program,omitempty"`
39 ClaimScript chainjson.HexBytes `json:"claim_script"`
42 func (a *API) getPeginAddress(ctx context.Context, ins rpc.ClaimArgs) Response {
44 pegin := &rpc.BytomPeginRpc{
49 resp, err := pegin.GetPeginAddress()
51 return NewErrorResponse(err)
54 return NewSuccessResponse(resp)
57 func (a *API) getPeginContractAddress(ctx context.Context, ins struct {
58 AccountID string `json:"account_id"`
59 AccountAlias string `json:"account_alias"`
61 pegin := &rpc.BytomPeginRpc{
65 resp, err := pegin.GetPeginContractAddress()
67 return NewErrorResponse(err)
70 return NewSuccessResponse(resp)