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.
This commit is contained in:
parent
40cdacde23
commit
a3ccc25e5a
1 changed files with 8 additions and 6 deletions
|
@ -1386,20 +1386,22 @@ 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
|
||||
}
|
||||
}
|
||||
|
||||
return tx.Sha().String(), nil
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue