github.com/algorand/go-algorand-sdk@v1.24.0/client/v2/algod/rawTransaction.go (about) 1 package algod 2 3 import ( 4 "context" 5 "strings" 6 7 "github.com/algorand/go-algorand-sdk/client/v2/common" 8 "github.com/algorand/go-algorand-sdk/client/v2/common/models" 9 ) 10 11 // SendRawTransaction broadcasts a raw transaction to the network. 12 type SendRawTransaction struct { 13 c *Client 14 15 rawtxn []byte 16 } 17 18 // Do performs the HTTP request 19 func (s *SendRawTransaction) Do(ctx context.Context, headers ...*common.Header) (txid string, err error) { 20 var response models.PostTransactionsResponse 21 // Set default Content-Type, if the user didn't specify it. 22 addContentType := true 23 for _, header := range headers { 24 if strings.ToLower(header.Key) == "content-type" { 25 addContentType = false 26 break 27 } 28 } 29 if addContentType { 30 headers = append(headers, &common.Header{"Content-Type", "application/x-binary"}) 31 } 32 err = s.c.post(ctx, &response, "/v2/transactions", nil, headers, s.rawtxn) 33 txid = response.Txid 34 return 35 }