// SendTransaction calls the /tx/send endpoint to send a raw payload.
// Payloads are best crafted with wavelet.Transfer.
SendTransaction calls the /tx/send endpoint to send a raw payload.
Payloads are best crafted with wavelet.Transfer.
// SendTransaction calls the / tx / send endpoint to send a raw payload . // Payloads are best crafted with wavelet . Transfer .
func (c *Client) SendTransaction(tag byte, payload []byte) (*TxResponse, error) {
	var res TxResponse
	nonce := uint64(time.Now().UnixNano())
	block := c.Block.Load()
	var nonceBuf [8]byte
	binary.BigEndian.PutUint64(nonceBuf[:], nonce)
	var blockBuf [8]byte
	binary.BigEndian.PutUint64(blockBuf[:], block)
	signature := edwards25519.Sign(
		c.PrivateKey,
		append(nonceBuf[:], append(blockBuf[:], append([]byte{tag}, payload...)...)...),
	)
	req := TxRequest{
		Sender:    c.PublicKey,
		Nonce:     nonce,
		Block:     block,
		Tag:       tag,
		Payload:   payload,
		Signature: signature,
	}
	if err := c.RequestJSON(RouteTxSend, ReqPost, &req, &res); err != nil {
		return nil, err
	}
	return &res, nil
}
func ( c * Client ) SendTransaction ( tag byte , payload [ ] byte ) ( * TxResponse , error ) { var res TxResponse nonce := uint64 ( time . Now ( ) . UnixNano ( ) ) block := c . Block . Load ( ) var nonceBuf [ 8 ] byte binary . BigEndian . PutUint64 ( nonceBuf [ : ] , nonce ) var blockBuf [ 8 ] byte binary . BigEndian . PutUint64 ( blockBuf [ : ] , block ) signature := edwards25519 . Sign ( c . PrivateKey , append ( nonceBuf [ : ] , append ( blockBuf [ : ] , append ( [ ] byte { tag } , payload ... ) ... ) ... ) , ) req := TxRequest { Sender : c . PublicKey , Nonce : nonce , Block : block , Tag : tag , Payload : payload , Signature : signature , } if err := c . RequestJSON ( RouteTxSend , ReqPost , & req , & res ) ; err != nil { return nil , err } return & res , nil }
SendTransaction calls the /tx/send endpoint to send a raw payload.
SendTransaction calls the / tx / send endpoint to send a raw payload .