Fix sendrawtransaction for websockets.
This fixes two issues: first, the sendrawtransaction handler had an extra character in the key in the websocket handler map, preventing the handler from never running. Second, a nil pointer dereference was removed from the handler. This change fixes the minedtx notifications for btcwallet, since the websocket-handler now runs instead of falling back to the legacy RPC handler.
This commit is contained in:
parent
f12ca20372
commit
d3e4bcdcf5
1 changed files with 14 additions and 15 deletions
|
@ -35,13 +35,13 @@ type wsCommandHandler func(*rpcServer, btcjson.Cmd, handlerChans) (interface{},
|
||||||
// wsHandlers maps RPC command strings to appropriate websocket handler
|
// wsHandlers maps RPC command strings to appropriate websocket handler
|
||||||
// functions.
|
// functions.
|
||||||
var wsHandlers = map[string]wsCommandHandler{
|
var wsHandlers = map[string]wsCommandHandler{
|
||||||
"getcurrentnet": handleGetCurrentNet,
|
"getcurrentnet": handleGetCurrentNet,
|
||||||
"getbestblock": handleGetBestBlock,
|
"getbestblock": handleGetBestBlock,
|
||||||
"notifyblocks": handleNotifyBlocks,
|
"notifyblocks": handleNotifyBlocks,
|
||||||
"notifynewtxs": handleNotifyNewTXs,
|
"notifynewtxs": handleNotifyNewTXs,
|
||||||
"notifyspent": handleNotifySpent,
|
"notifyspent": handleNotifySpent,
|
||||||
"rescan": handleRescan,
|
"rescan": handleRescan,
|
||||||
"sendrawtransaction:": handleWalletSendRawTransaction,
|
"sendrawtransaction": handleWalletSendRawTransaction,
|
||||||
}
|
}
|
||||||
|
|
||||||
// wsContext holds the items the RPC server needs to handle websocket
|
// wsContext holds the items the RPC server needs to handle websocket
|
||||||
|
@ -492,15 +492,14 @@ func handleWalletSendRawTransaction(s *rpcServer, icmd btcjson.Cmd, c handlerCha
|
||||||
// TODO: the standard handlers really should be changed to
|
// TODO: the standard handlers really should be changed to
|
||||||
// return btcjson.Errors which get used directly in the
|
// return btcjson.Errors which get used directly in the
|
||||||
// response. Wouldn't need this crap here then.
|
// response. Wouldn't need this crap here then.
|
||||||
var jsonErr *btcjson.Error
|
|
||||||
if jsonErr, ok := err.(*btcjson.Error); ok {
|
|
||||||
return result, jsonErr
|
|
||||||
}
|
|
||||||
jsonErr = &btcjson.Error{
|
|
||||||
Code: btcjson.ErrMisc.Code,
|
|
||||||
Message: err.Error(),
|
|
||||||
}
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
if jsonErr, ok := err.(*btcjson.Error); ok {
|
||||||
|
return result, jsonErr
|
||||||
|
}
|
||||||
|
jsonErr := &btcjson.Error{
|
||||||
|
Code: btcjson.ErrMisc.Code,
|
||||||
|
Message: err.Error(),
|
||||||
|
}
|
||||||
return result, jsonErr
|
return result, jsonErr
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue