func newTransaction(nonce uint64, to *common.Address, amount *big.Int, gasLimit uint64, gasPrice *big.Int, data []byte, from *common.Address) *types.Transaction {
	if len(data) > 0 {
		data = CopyBytes(data)
	}
	d := types.TxData{
		AccountNonce: nonce,
		Recipient:    TypeConvert(to),
		From:         TypeConvert(from),
		Payload:      data,
		Amount:       new(big.Int),
		GasLimit:     gasLimit,
		Price:        new(big.Int),
		V:            new(big.Int),
		R:            new(big.Int),
		S:            new(big.Int),
	}
	if amount != nil {
		d.Amount.Set(amount)
	}
	if gasPrice != nil {
		d.Price.Set(gasPrice)
	}
	return &types.Transaction{Data: d}
}
New a transaction
package types
import (
	"github.com/DSiSc/crypto-suite/rlp"
	"io"
	"math/big"
	"github.com/DSiSc/craft/types"
	"github.com/DSiSc/wallet/common"
)
func CopyBytes(b []byte) (copiedBytes []byte) {
	if b == nil {
		return nil
	}
	copiedBytes = make([]byte, len(b))
	copy(copiedBytes, b)
	return
}
func TypeConvert(a *common.Address) *types.Address {
	var address types.Address
	copy(address[:], a[:])
	return &address
}