OSDN Git Service

fix bug for cancel vote (#145)
authorwz <mars@bytom.io>
Mon, 10 Jun 2019 06:40:28 +0000 (14:40 +0800)
committerPaladz <yzhu101@uottawa.ca>
Mon, 10 Jun 2019 06:40:28 +0000 (14:40 +0800)
account/builder.go

index 027e1fb..af0c0a1 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.NewUnvoteInput(nil, u.SourceID, u.AssetID, u.Amount, u.SourcePos, u.ControlProgram, u.Vote)
+       }
        sigInst := &txbuilder.SigningInstruction{}
        if signer == nil {
                return txInput, sigInst, nil