6 "github.com/vapor/blockchain/txbuilder"
7 chainjson "github.com/vapor/encoding/json"
10 func (a *API) createAccountReceiver(ctx context.Context, ins struct {
11 AccountID string `json:"account_id"`
12 AccountAlias string `json:"account_alias"`
14 accountID := ins.AccountID
15 if ins.AccountAlias != "" {
16 account, err := a.wallet.AccountMgr.FindByAlias(ins.AccountAlias)
18 return NewErrorResponse(err)
21 accountID = account.ID
24 program, err := a.wallet.AccountMgr.CreateAddress(accountID, false)
26 return NewErrorResponse(err)
29 return NewSuccessResponse(&txbuilder.Receiver{
30 ControlProgram: program.ControlProgram,
31 Address: program.Address,
35 type fundingResp struct {
36 MainchainAddress string `json:"mainchain_address"`
37 ClaimScript chainjson.HexBytes `json:"claim_script"`
40 func (a *API) getPeginAddress(ctx context.Context, ins struct {
41 AccountID string `json:"account_id"`
42 AccountAlias string `json:"account_alias"`
45 accountID := ins.AccountID
46 if ins.AccountAlias != "" {
47 account, err := a.wallet.AccountMgr.FindByAlias(ins.AccountAlias)
49 return NewErrorResponse(err)
52 accountID = account.ID
55 mainchainAddress, claimScript, err := a.wallet.AccountMgr.CreatePeginAddress(accountID, false)
57 return NewErrorResponse(err)
60 return NewSuccessResponse(fundingResp{
61 MainchainAddress: mainchainAddress,
62 ClaimScript: claimScript,