7 log "github.com/sirupsen/logrus"
8 "github.com/vapor/account"
9 "github.com/vapor/blockchain/pseudohsm"
10 "github.com/vapor/blockchain/txbuilder"
11 "github.com/vapor/config"
12 "github.com/vapor/crypto/ed25519/chainkd"
13 "github.com/vapor/protocol/bc"
16 func (a *API) registe(ctx context.Context, ins struct {
17 DelegateAddress string `json:"delegate_address"`
18 DelegateName string `json:"delegate_name"`
23 return NewSuccessResponse("")
26 func (a *API) dpos(ctx context.Context, ins struct {
27 From string `json:"from"`
29 Fee uint64 `json:"fee"`
30 Stake uint64 `json:"stake"`
31 TxType uint32 `json:"tx_type"`
34 var assetID bc.AssetID
35 assetID.UnmarshalText([]byte("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"))
37 dpos := account.DopsAction{
38 Accounts: a.wallet.AccountMgr,
44 dpos.Amount = ins.Stake
45 dpos.AssetId = &assetID
46 builder := txbuilder.NewBuilder(time.Now())
47 if err := dpos.Build(ctx, builder); err != nil {
48 return NewErrorResponse(err)
52 tmpl, _, err := builder.Build()
54 return NewErrorResponse(err)
57 xprv.UnmarshalText([]byte(config.CommonConfig.Consensus.Dpos.XPrv))
58 if err := pseudohsm.SignWithKey(tmpl, xprv); err != nil {
59 return NewErrorResponse(err)
61 log.Info("Sign Transaction complete.")
62 log.Info(txbuilder.SignProgress(tmpl))
63 //return NewSuccessResponse(&signTemplateResp{Tx: tmpl, SignComplete: txbuilder.SignProgress(tmpl)})
66 if err := txbuilder.FinalizeTx(ctx, a.chain, tmpl.Transaction); err != nil {
67 return NewErrorResponse(err)
70 log.WithField("tx_id", tmpl.Transaction.ID.String()).Info("submit single tx")
71 return NewSuccessResponse(&submitTxResp{TxID: &tmpl.Transaction.ID})