OSDN Git Service

Merge branch 'dev' into dev-verify
[bytom/bytom.git] / account / builder.go
index 3d1eb82..95a191d 100644 (file)
@@ -43,7 +43,7 @@ func (a *spendAction) Build(ctx context.Context, b *txbuilder.TemplateBuilder) e
                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")
        }
@@ -115,7 +115,7 @@ func (a *spendUTXOAction) Build(ctx context.Context, b *txbuilder.TemplateBuilde
 
        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
                }
@@ -152,7 +152,7 @@ func UtxoToInputs(signer *signers.Signer, u *UTXO) (*types.TxInput, *txbuilder.S
                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
        }
@@ -182,41 +182,6 @@ func UtxoToInputs(signer *signers.Signer, u *UTXO) (*types.TxInput, *txbuilder.S
        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