OSDN Git Service

filter change output (#248)
[bytom/vapor.git] / account / builder.go
index 027e1fb..5f2448a 100644 (file)
@@ -309,7 +309,12 @@ func (a *spendUTXOAction) Build(ctx context.Context, b *txbuilder.TemplateBuilde
 
 // UtxoToInputs convert an utxo to the txinput
 func UtxoToInputs(signer *signers.Signer, u *UTXO) (*types.TxInput, *txbuilder.SigningInstruction, error) {
-       txInput := types.NewSpendInput(nil, u.SourceID, u.AssetID, u.Amount, u.SourcePos, u.ControlProgram)
+       txInput := &types.TxInput{}
+       if u.Vote == nil {
+               txInput = types.NewSpendInput(nil, u.SourceID, u.AssetID, u.Amount, u.SourcePos, u.ControlProgram)
+       } else {
+               txInput = types.NewVetoInput(nil, u.SourceID, u.AssetID, u.Amount, u.SourcePos, u.ControlProgram, u.Vote)
+       }
        sigInst := &txbuilder.SigningInstruction{}
        if signer == nil {
                return txInput, sigInst, nil
@@ -381,13 +386,13 @@ func (m *Manager) insertControlProgramDelayed(b *txbuilder.TemplateBuilder, acp
        })
 }
 
-//DecodeUnvoteAction unmarshal JSON-encoded data of spend action
-func (m *Manager) DecodeUnvoteAction(data []byte) (txbuilder.Action, error) {
-       a := &unvoteAction{accounts: m}
+//DecodeVetoAction unmarshal JSON-encoded data of spend action
+func (m *Manager) DecodeVetoAction(data []byte) (txbuilder.Action, error) {
+       a := &vetoAction{accounts: m}
        return a, stdjson.Unmarshal(data, a)
 }
 
-type unvoteAction struct {
+type vetoAction struct {
        accounts *Manager
        bc.AssetAmount
        AccountID      string        `json:"account_id"`
@@ -395,11 +400,11 @@ type unvoteAction struct {
        UseUnconfirmed bool          `json:"use_unconfirmed"`
 }
 
-func (a *unvoteAction) ActionType() string {
-       return "unvote"
+func (a *vetoAction) ActionType() string {
+       return "veto"
 }
 
-func (a *unvoteAction) Build(ctx context.Context, b *txbuilder.TemplateBuilder) error {
+func (a *vetoAction) Build(ctx context.Context, b *txbuilder.TemplateBuilder) error {
        var missing []string
        if a.AccountID == "" {
                missing = append(missing, "account_id")