func (a *API) submit(ctx context.Context, ins struct {
Tx types.Tx `json:"raw_transaction"`
}) Response {
- if err := txbuilder.FinalizeTx(ctx, a.chain, &ins.Tx); err != nil {
+ txCh := a.sync.GetNewTxCh()
+ if err := txbuilder.FinalizeTx(ctx, txCh, &ins.Tx); err != nil {
return NewErrorResponse(err)
}
"context"
"github.com/bytom/errors"
- "github.com/bytom/protocol"
"github.com/bytom/protocol/bc/types"
"github.com/bytom/protocol/vm"
)
// FinalizeTx validates a transaction signature template,
// assembles a fully signed tx, and stores the effects of
// its changes on the UTXO set.
-func FinalizeTx(ctx context.Context, c *protocol.Chain, tx *types.Tx) error {
+func FinalizeTx(ctx context.Context, txCh chan *types.Tx,tx *types.Tx) error {
if err := checkTxSighashCommitment(tx); err != nil {
return err
}
tx.TxData.SerializedSize = uint64(len(data))
tx.Tx.SerializedSize = uint64(len(data))
- _, err = c.ValidateTx(tx)
- if errors.Root(err) == protocol.ErrBadTx {
- return errors.Sub(ErrRejected, err)
- }
- if err != nil {
- return errors.WithDetail(err, "tx rejected: "+err.Error())
- }
+ txCh <- tx
return errors.Wrap(err)
}