return txbuilder.MissingFieldsError(missing...)
}
- acct, err := a.accounts.findByID(ctx, a.AccountID)
+ acct, err := a.accounts.FindByID(ctx, a.AccountID)
if err != nil {
return errors.Wrap(err, "get account info")
}
var accountSigner *signers.Signer
if len(res.Source.AccountID) != 0 {
- account, err := a.accounts.findByID(ctx, res.Source.AccountID)
+ account, err := a.accounts.FindByID(ctx, res.Source.AccountID)
if err != nil {
return err
}
return txInput, sigInst, nil
}
- address, err := common.DecodeAddress(u.Address, &consensus.MainNetParams)
+ address, err := common.DecodeAddress(u.Address, &consensus.ActiveNetParams)
if err != nil {
return nil, nil, err
}
return txInput, sigInst, nil
}
-//DecodeControlAction unmarshal JSON-encoded data of control action
-func (m *Manager) DecodeControlAction(data []byte) (txbuilder.Action, error) {
- a := &controlAction{accounts: m}
- err := json.Unmarshal(data, a)
- return a, err
-}
-
-type controlAction struct {
- accounts *Manager
- bc.AssetAmount
- AccountID string `json:"account_id"`
-}
-
-func (a *controlAction) Build(ctx context.Context, b *txbuilder.TemplateBuilder) error {
- var missing []string
- if a.AccountID == "" {
- missing = append(missing, "account_id")
- }
- if a.AssetId.IsZero() {
- missing = append(missing, "asset_id")
- }
- if len(missing) > 0 {
- return txbuilder.MissingFieldsError(missing...)
- }
-
- // Produce a control program, but don't insert it into the database yet.
- acp, err := a.accounts.CreateAddress(ctx, a.AccountID, false)
- if err != nil {
- return err
- }
- a.accounts.insertControlProgramDelayed(ctx, b, acp)
-
- return b.AddOutput(types.NewTxOutput(*a.AssetId, a.Amount, acp.ControlProgram))
-}
-
// insertControlProgramDelayed takes a template builder and an account
// control program that hasn't been inserted to the database yet. It
// registers callbacks on the TemplateBuilder so that all of the template's