Skip to content

Commit

Permalink
Fix unbound outpoint server error (#2479)
Browse files Browse the repository at this point in the history
  • Loading branch information
raphjaph authored Nov 16, 2023
1 parent 86ddcf5 commit f1e3c50
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
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);
}

0 comments on commit f1e3c50

Please sign in to comment.