@@ -179,7 +179,7 @@ func (d *proxyDialer) dialProxy(ctx context.Context, addr string) (net.Conn, err
179
179
addr , addr , d .auth ,
180
180
)
181
181
182
- if _ , err : = conn .Write ([]byte (connectReq )); err != nil {
182
+ if _ , err = conn .Write ([]byte (connectReq )); err != nil {
183
183
conn .Close ()
184
184
return nil , fmt .Errorf ("failed to write CONNECT request: %w" , err )
185
185
}
@@ -416,14 +416,33 @@ type BroadcastBundleResponse struct {
416
416
}
417
417
418
418
// BroadcastBundle sends a bundle through Jito API.
419
- func BroadcastBundle (client * http.Client , transactions []string ) (* BroadcastBundleResponse , error ) {
419
+ func BroadcastBundle (client * http.Client , encoding Encoding , transactions []* solana. Transaction ) (* BroadcastBundleResponse , error ) {
420
420
buf := new (bytes.Buffer )
421
421
422
+ var txns []string
423
+ var err error
424
+ switch encoding {
425
+ case Base58 :
426
+ txns , err = pkg .ConvertBachTransactionsToBase58 (transactions )
427
+ if err != nil {
428
+ return nil , err
429
+ }
430
+ break
431
+ case Base64 :
432
+ txns , err = pkg .ConvertBachTransactionsToBase64 (transactions )
433
+ if err != nil {
434
+ return nil , err
435
+ }
436
+ break
437
+ default :
438
+ return nil , errors .New ("unknown encoding, expected base64 or base58" )
439
+ }
440
+
422
441
payload := map [string ]any {
423
442
"jsonrpc" : "2.0" ,
424
443
"id" : 1 ,
425
444
"method" : "sendBundle" ,
426
- "params" : [][]string {transactions },
445
+ "params" : [][]string {txns },
427
446
}
428
447
429
448
if err := json .NewEncoder (buf ).Encode (payload ); err != nil {
@@ -453,12 +472,8 @@ func BroadcastBundle(client *http.Client, transactions []string) (*BroadcastBund
453
472
}
454
473
455
474
// BroadcastBundleWithConfirmation sends a bundle of transactions on chain through Jito BlockEngine and waits for its confirmation.
456
- func BroadcastBundleWithConfirmation (ctx context.Context , client * http.Client , rpcConn * rpc.Client , transactions []* solana.Transaction ) (* BroadcastBundleResponse , error ) {
457
- txsBase58 , err := pkg .ConvertBachTransactionsToBase58 (transactions )
458
- if err != nil {
459
- return nil , err
460
- }
461
- bundle , err := BroadcastBundle (client , txsBase58 )
475
+ func BroadcastBundleWithConfirmation (ctx context.Context , client * http.Client , rpcConn * rpc.Client , encoding Encoding , transactions []* solana.Transaction ) (* BroadcastBundleResponse , error ) {
476
+ bundle , err := BroadcastBundle (client , encoding , transactions )
462
477
if err != nil {
463
478
return nil , err
464
479
}
0 commit comments