@@ -14,15 +14,15 @@ type RawTransactionResponse struct {
14
14
ErrMsg string `json:"errmsg"`
15
15
}
16
16
17
- func sendRawTransaction (txHex string ) (resp RawTransactionResponse , err error ) {
17
+ func sendRawTransaction (txHex string ) (resp RawTransactionResponse ) {
18
18
// try bitcoind first
19
19
if bitcoind != nil {
20
20
tx := & wire.MsgTx {}
21
21
if txBytes , err := hex .DecodeString (txHex ); err == nil {
22
22
txBuf := bytes .NewBuffer (txBytes )
23
23
if err := tx .BtcDecode (txBuf , wire .ProtocolVersion , wire .WitnessEncoding ); err == nil {
24
24
if _ , err := bitcoind .SendRawTransaction (tx , true ); err == nil {
25
- return RawTransactionResponse {true , "" }, nil
25
+ return RawTransactionResponse {true , "" }
26
26
}
27
27
}
28
28
}
@@ -31,9 +31,9 @@ func sendRawTransaction(txHex string) (resp RawTransactionResponse, err error) {
31
31
// then try explorers
32
32
tx := bytes .NewBufferString (txHex )
33
33
for _ , endpoint := range esploras (network ) {
34
- w , errW := http .Post (endpoint + "/tx" , "text/plain" , tx )
35
- if errW != nil {
36
- err = errW
34
+ w , err := http .Post (endpoint + "/tx" , "text/plain" , tx )
35
+ if err != nil {
36
+ resp = RawTransactionResponse { false , err . Error ()}
37
37
continue
38
38
}
39
39
defer w .Body .Close ()
@@ -45,8 +45,8 @@ func sendRawTransaction(txHex string) (resp RawTransactionResponse, err error) {
45
45
continue
46
46
}
47
47
48
- return RawTransactionResponse {true , "" }, nil
48
+ return RawTransactionResponse {true , "" }
49
49
}
50
50
51
- return resp , err
51
+ return resp
52
52
}
0 commit comments