@@ -64,7 +64,7 @@ func (a *Arc) Broadcast(t *transaction.Transaction) (*transaction.BroadcastSucce
6464 return a .BroadcastCtx (context .Background (), t )
6565}
6666
67- func (a * Arc ) BroadcastCtx (ctx context.Context , t * transaction.Transaction ) (* transaction. BroadcastSuccess , * transaction. BroadcastFailure ) {
67+ func (a * Arc ) ArcBroadcast (ctx context.Context , t * transaction.Transaction ) (* ArcResponse , error ) {
6868 var buf * bytes.Buffer
6969 for _ , input := range t .Inputs {
7070 if input .SourceTxOutput () == nil {
@@ -74,10 +74,7 @@ func (a *Arc) BroadcastCtx(ctx context.Context, t *transaction.Transaction) (*tr
7474 }
7575 if buf == nil {
7676 if ef , err := t .EF (); err != nil {
77- return nil , & transaction.BroadcastFailure {
78- Code : "500" ,
79- Description : err .Error (),
80- }
77+ return nil , err
8178 } else {
8279 buf = bytes .NewBuffer (ef )
8380 }
@@ -90,10 +87,7 @@ func (a *Arc) BroadcastCtx(ctx context.Context, t *transaction.Transaction) (*tr
9087 buf ,
9188 )
9289 if err != nil {
93- return nil , & transaction.BroadcastFailure {
94- Code : "500" ,
95- Description : err .Error (),
96- }
90+ return nil , err
9791 }
9892
9993 req .Header .Set ("Content-Type" , "application/octet-stream" )
@@ -140,25 +134,28 @@ func (a *Arc) BroadcastCtx(ctx context.Context, t *transaction.Transaction) (*tr
140134 }
141135 resp , err := a .Client .Do (req )
142136 if err != nil {
143- return nil , & transaction.BroadcastFailure {
144- Code : "500" ,
145- Description : err .Error (),
146- }
137+ return nil , err
147138 }
148139 defer resp .Body .Close ()
149140 msg , err := io .ReadAll (resp .Body )
150141 if err != nil {
151- return nil , & transaction.BroadcastFailure {
152- Code : "500" ,
153- Description : err .Error (),
154- }
142+ return nil , err
155143 }
156144
157145 response := & ArcResponse {}
158146 if a .Verbose {
159147 log .Println ("msg" , string (msg ))
160148 }
161149 err = json .Unmarshal (msg , & response )
150+ if err != nil {
151+ return nil , err
152+ }
153+
154+ return response , nil
155+ }
156+
157+ func (a * Arc ) BroadcastCtx (ctx context.Context , t * transaction.Transaction ) (* transaction.BroadcastSuccess , * transaction.BroadcastFailure ) {
158+ response , err := a .ArcBroadcast (ctx , t )
162159 if err != nil {
163160 return nil , & transaction.BroadcastFailure {
164161 Code : "500" ,
0 commit comments