From a3ccc25e5a8cc35123f075c46dd59897f3d1b27e Mon Sep 17 00:00:00 2001 From: Josh Rickmar Date: Fri, 21 Feb 2014 09:03:04 -0500 Subject: [PATCH] Return errors for any sendrawtransaction rejection. This changes the implementation of the sendrawtransaction RPC handler to match bitcoind behavior by always returning a rejection error for any error processing or accepting the tx by the mempool. Previously, if the tx was rejected for a rule error rather than an actual failure, a client would still receive the tx sha as a result with no error. --- rpcserver.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/rpcserver.go b/rpcserver.go index 9a45fd93b..450a7abca 100644 --- a/rpcserver.go +++ b/rpcserver.go @@ -1386,19 +1386,21 @@ func handleSendRawTransaction(s *rpcServer, cmd btcjson.Cmd) (interface{}, error // When the error is a rule error, it means the transaction was // simply rejected as opposed to something actually going wrong, // so log it as such. Otherwise, something really did go wrong, - // so log it as an actual error. + // so log it as an actual error. In both cases, a JSON-RPC + // error is returned to the client with the deserialization + // error code (to match bitcoind behavior). if _, ok := err.(TxRuleError); ok { rpcsLog.Debugf("Rejected transaction %v: %v", tx.Sha(), err) } else { rpcsLog.Errorf("Failed to process transaction %v: %v", tx.Sha(), err) - err = btcjson.Error{ - Code: btcjson.ErrDeserialization.Code, - Message: "TX rejected", - } - return nil, err } + err = btcjson.Error{ + Code: btcjson.ErrDeserialization.Code, + Message: "TX rejected", + } + return nil, err } return tx.Sha().String(), nil