Skip to content

Commit

Permalink
Fix non-existant output lookup (#3968)
Browse files Browse the repository at this point in the history
  • Loading branch information
raphjaph authored Oct 2, 2024
1 parent e71efa1 commit bee7bf6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,15 @@ impl<T> BitcoinCoreRpcResultExt<T> for Result<T, bitcoincore_rpc::Error> {
Err(bitcoincore_rpc::Error::JsonRpc(bitcoincore_rpc::jsonrpc::error::Error::Rpc(
bitcoincore_rpc::jsonrpc::error::RpcError { code: -8, .. },
))) => Ok(None),
Err(bitcoincore_rpc::Error::JsonRpc(bitcoincore_rpc::jsonrpc::error::Error::Rpc(
bitcoincore_rpc::jsonrpc::error::RpcError {
code: -5, message, ..
},
)))
if message.starts_with("No such mempool or blockchain transaction") =>
{
Ok(None)
}
Err(bitcoincore_rpc::Error::JsonRpc(bitcoincore_rpc::jsonrpc::error::Error::Rpc(
bitcoincore_rpc::jsonrpc::error::RpcError { message, .. },
)))
Expand Down
10 changes: 10 additions & 0 deletions src/subcommand/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7152,4 +7152,14 @@ next
}
);
}

#[test]
fn unknown_output_returns_404() {
let server = TestServer::builder().chain(Chain::Regtest).build();
server.assert_response(
"/output/0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef:123",
StatusCode::NOT_FOUND,
"output 0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef:123 not found",
);
}
}

0 comments on commit bee7bf6

Please sign in to comment.