Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix unbound outpoint server error #2479

Merged
merged 10 commits into from
Nov 16, 2023
2 changes: 1 addition & 1 deletion src/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1128,7 +1128,7 @@ impl Index {
}

pub(crate) fn list(&self, outpoint: OutPoint) -> Result<Option<List>> {
if !self.index_sats {
if !self.index_sats || outpoint == unbound_outpoint() {
return Ok(None);
}

Expand Down
13 changes: 12 additions & 1 deletion src/subcommand/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2575,7 +2575,7 @@ mod tests {

#[test]
fn unbound_output_receives_unbound_inscriptions() {
let server = TestServer::new_with_regtest();
let server = TestServer::new_with_regtest_with_index_sats();

server.mine_blocks(1);

Expand Down Expand Up @@ -2611,6 +2611,17 @@ mod tests {
<dd><a class=monospace href=/output/0000000000000000000000000000000000000000000000000000000000000000:0>0000000000000000000000000000000000000000000000000000000000000000:0</a></dd>.*"
),
);

server.assert_response_regex(
"/output/0000000000000000000000000000000000000000000000000000000000000000:0",
StatusCode::OK,
".*<h1>Output <span class=monospace>0000000000000000000000000000000000000000000000000000000000000000:0</span></h1>
<dl>
<dt>inscriptions</dt>
<dd class=thumbnails>
<a href=/inscription/.*><iframe sandbox=allow-scripts scrolling=no loading=lazy src=/preview/.*></iframe></a>
</dd>.*",
);
}

#[test]
Expand Down
19 changes: 19 additions & 0 deletions tests/wallet/outputs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,22 @@ fn outputs_includes_locked_outputs() {
assert_eq!(output[0].output, outpoint);
assert_eq!(output[0].amount, amount);
}

#[test]
fn outputs_includes_unbound_outputs() {
let rpc_server = test_bitcoincore_rpc::spawn();
create_wallet(&rpc_server);

let coinbase_tx = &rpc_server.mine_blocks_with_subsidy(1, 1_000_000)[0].txdata[0];
let outpoint = OutPoint::new(coinbase_tx.txid(), 0);
let amount = coinbase_tx.output[0].value;

rpc_server.lock(outpoint);

let output = CommandBuilder::new("wallet outputs")
.rpc_server(&rpc_server)
.run_and_deserialize_output::<Vec<Output>>();

assert_eq!(output[0].output, outpoint);
assert_eq!(output[0].amount, amount);
}
Loading