OSDN Git Service

don't use change (#2013)
authorPaladz <yzhu101@uottawa.ca>
Mon, 5 Jul 2021 07:14:17 +0000 (15:14 +0800)
committerGitHub <noreply@github.com>
Mon, 5 Jul 2021 07:14:17 +0000 (15:14 +0800)
Co-authored-by: paladz <colt@ColtdeMacBook-Pro.local>
account/builder.go

index 03312c8..8e7be29 100644 (file)
@@ -235,15 +235,7 @@ func (a *spendAction) Build(ctx context.Context, b *txbuilder.TemplateBuilder) e
        }
 
        if res.change > 0 {
-               acp, err := a.accounts.CreateAddress(a.AccountID, true)
-               if err != nil {
-                       return errors.Wrap(err, "creating control program")
-               }
-
-               // Don't insert the control program until callbacks are executed.
-               a.accounts.insertControlProgramDelayed(b, acp)
-               // TODL: fill account state data
-               if err = b.AddOutput(types.NewOriginalTxOutput(*a.AssetId, res.change, acp.ControlProgram, nil)); err != nil {
+               if err = b.AddOutput(types.NewOriginalTxOutput(*a.AssetId, res.change, res.utxos[0].ControlProgram, nil)); err != nil {
                        return errors.Wrap(err, "adding change output")
                }
        }