Skip to main content

keep_bitcoin/
chain_view.rs

1// SPDX-FileCopyrightText: © 2026 PrivKey LLC
2// SPDX-License-Identifier: MIT
3
4//! Chain-view abstraction for responder-side prevout validation (#502).
5//!
6//! A responder trusts the proposer to hand it a PSBT whose `witness_utxo`
7//! values reflect the real on-chain UTXOs it is being asked to spend.
8//! BIP-341 taproot signatures commit to every input's prevout amount, so an
9//! understated amount produces a signature that is valid on-chain but
10//! bypasses every fee cap the responder computed against the (lied about)
11//! claim: the destination check in `validate_migration_sweep_destination`
12//! catches the receiving script, but a proposer can still drain the delta
13//! between the honest amount and the declared amount into fees.
14//!
15//! [`ChainView`] is the read-only interface responders use to fetch the
16//! authoritative amount+script for each PSBT input. Implementations can
17//! back it with an esplora/blockstream HTTP endpoint (the built-in
18//! [`EsploraChainView`], gated on the `esplora-chain-view` feature), a
19//! bitcoind JSON-RPC client, or a mock for tests.
20//!
21//! Signing sites invoke [`validate_prevout_amounts_against_chain`] before
22//! forwarding a PSBT sighash. A mismatch aborts the signing with the same
23//! shape of `REFUSED:` error the destination guard uses, so operators see
24//! the two defenses side by side.
25
26use bitcoin::{OutPoint, Psbt, TxOut};
27
28/// Read-only view resolving an outpoint's committed `(value, script_pubkey)`
29/// for #502 prevout validation.
30///
31/// Implementations MUST return the exact `(value_sats, script_pubkey)` the
32/// outpoint's transaction commits to, so a responder can compare it against
33/// the PSBT's proposer-supplied `witness_utxo`. Amounts and scripts are
34/// committed to the txid, so this is authoritative for the amount check.
35/// It does NOT prove the outpoint is unspent or confirmed. Returning a
36/// stale or approximate value defeats the check.
37pub trait ChainView {
38    /// Fetch the committed `(value, script_pubkey)` of `outpoint`. Returns
39    /// `ChainViewError::NotFound` when the transaction or output does not
40    /// exist on the chain view's backing endpoint (itself refusal-worthy:
41    /// the responder cannot run the amount check without an authoritative
42    /// prevout). The returned amount is authoritative because it is
43    /// committed to the txid; this does not attest that the output is
44    /// unspent.
45    fn get_prevout(&self, outpoint: OutPoint) -> Result<TxOut, ChainViewError>;
46}
47
48/// Errors surfaced by a [`ChainView`] implementation.
49#[derive(Debug, thiserror::Error)]
50pub enum ChainViewError {
51    /// The requested outpoint is not visible on the chain view's endpoint.
52    #[error("outpoint {txid}:{vout} not found on chain view")]
53    NotFound { txid: bitcoin::Txid, vout: u32 },
54    /// Network / transport error contacting the backing endpoint. Callers
55    /// MUST NOT treat this as "no divergence"; it's an inconclusive read and
56    /// the responder is expected to refuse signing.
57    #[error("chain view transport error: {0}")]
58    Transport(String),
59    /// The backing endpoint returned a malformed response the client could
60    /// not decode.
61    #[error("chain view response decode error: {0}")]
62    Decode(String),
63    /// The chain view was misconfigured (e.g. an invalid base URL).
64    #[error("chain view configuration error: {0}")]
65    Config(String),
66}
67
68/// Recompute-and-compare the proposer-declared prevout amount and script of
69/// every PSBT input against the authoritative chain view. Returns `Ok(())`
70/// only when every input's `witness_utxo` matches on both fields.
71///
72/// Amount mismatch is the #502 threat. A script mismatch is refusal-worthy
73/// for a different reason (the PSBT is signing over a UTXO the responder
74/// does not actually control), and the same defense catches both cheaply.
75///
76/// `Err` messages are shaped `REFUSED: ...` so operators see them
77/// alongside `validate_migration_sweep_destination`'s output.
78pub fn validate_prevout_amounts_against_chain(
79    psbt: &Psbt,
80    chain: &dyn ChainView,
81) -> Result<(), String> {
82    if psbt.inputs.is_empty() {
83        return Err(
84            "REFUSED: PSBT has no inputs; cannot validate prevout amounts against chain view."
85                .to_string(),
86        );
87    }
88    if psbt.inputs.len() != psbt.unsigned_tx.input.len() {
89        return Err(format!(
90            "REFUSED: PSBT input record count ({}) does not match unsigned tx input count ({}); refusing to sign.",
91            psbt.inputs.len(),
92            psbt.unsigned_tx.input.len(),
93        ));
94    }
95    for (idx, (psbt_input, tx_input)) in psbt
96        .inputs
97        .iter()
98        .zip(psbt.unsigned_tx.input.iter())
99        .enumerate()
100    {
101        let claimed = psbt_input.witness_utxo.as_ref().ok_or_else(|| {
102            format!(
103                "REFUSED: PSBT input {idx} has no witness_utxo; #502 amount validation requires \
104                 witness_utxo on every input. Refusing to sign."
105            )
106        })?;
107        let outpoint = tx_input.previous_output;
108        let actual = chain.get_prevout(outpoint).map_err(|e| {
109            format!(
110                "REFUSED: chain view could not resolve input {idx} outpoint {}:{}: {e}. \
111                 Refusing to sign without an authoritative prevout amount check.",
112                outpoint.txid, outpoint.vout,
113            )
114        })?;
115        if actual.value != claimed.value {
116            return Err(format!(
117                "REFUSED: input {idx} outpoint {}:{} amount mismatch. \
118                 Proposer declared {} sats but chain view says {} sats. \
119                 A BIP-341 sighash over an understated prevout amount defeats every fee cap; \
120                 refusing to sign.",
121                outpoint.txid,
122                outpoint.vout,
123                claimed.value.to_sat(),
124                actual.value.to_sat(),
125            ));
126        }
127        if actual.script_pubkey != claimed.script_pubkey {
128            return Err(format!(
129                "REFUSED: input {idx} outpoint {}:{} script_pubkey mismatch. \
130                 Proposer declared a different script than the chain view reports; \
131                 refusing to sign.",
132                outpoint.txid, outpoint.vout,
133            ));
134        }
135    }
136    Ok(())
137}
138
139/// Environment variable operators set to point every keep binary at a
140/// shared chain-view endpoint (`https://blockstream.info/api`,
141/// `https://mempool.space/api`, or a self-hosted esplora / mempool
142/// instance). Binaries that support #502 read this at signing time.
143pub const KEEP_CHAIN_URL_ENV: &str = "KEEP_CHAIN_URL";
144
145/// A [`ChainView`] impl backed by an esplora / mempool.space HTTP API,
146/// available under the `esplora-chain-view` feature. The endpoint is the
147/// same shape both providers ship (`GET /tx/{txid}` returning a full tx
148/// with `vout[].value`).
149#[cfg(feature = "esplora-chain-view")]
150pub struct EsploraChainView {
151    base_url: url::Url,
152    client: reqwest::blocking::Client,
153}
154
155#[cfg(feature = "esplora-chain-view")]
156fn is_loopback_url(url: &url::Url) -> bool {
157    match url.host() {
158        Some(url::Host::Domain(h)) => h.eq_ignore_ascii_case("localhost"),
159        Some(url::Host::Ipv4(ip)) => ip.is_loopback(),
160        Some(url::Host::Ipv6(ip)) => ip.is_loopback(),
161        None => false,
162    }
163}
164
165#[cfg(feature = "esplora-chain-view")]
166impl EsploraChainView {
167    /// Construct an Esplora chain view against a base URL of the form
168    /// `https://blockstream.info/api` (no trailing slash required). The
169    /// resulting client blocks on each request; call it from a non-async
170    /// thread or wrap with `tokio::task::block_in_place`.
171    pub fn new(base_url: impl AsRef<str>) -> Result<Self, ChainViewError> {
172        // Normalize with a trailing slash so downstream `Url::join("tx/...")`
173        // treats the base as a directory rather than dropping its final
174        // segment. `blockstream.info/api` and `blockstream.info/api/` behave
175        // identically to the operator; making that identity explicit here
176        // avoids a silent 404 that would look like "outpoint not found".
177        let raw = base_url.as_ref();
178        let normalized = if raw.ends_with('/') {
179            raw.to_string()
180        } else {
181            format!("{raw}/")
182        };
183        let base_url = url::Url::parse(&normalized).map_err(|e| {
184            ChainViewError::Config(format!("invalid chain view base URL {raw:?}: {e}"))
185        })?;
186        // MITM guard: the whole #502 check reduces to trusting this endpoint,
187        // so require https except for loopback (self-hosted / regtest esplora),
188        // where plaintext to localhost carries no network exposure.
189        if base_url.scheme() != "https" && !is_loopback_url(&base_url) {
190            return Err(ChainViewError::Config(format!(
191                "refusing non-https chain view URL {raw:?}: use https or a loopback host \
192                 (127.0.0.1, ::1, localhost) for plaintext."
193            )));
194        }
195        let client = reqwest::blocking::Client::builder()
196            .user_agent(concat!(
197                "keep/",
198                env!("CARGO_PKG_VERSION"),
199                " esplora-chain-view"
200            ))
201            .timeout(std::time::Duration::from_secs(15))
202            // Refuse redirects that downgrade https -> a non-https, non-loopback
203            // next hop; a redirecting endpoint must not strip transport security.
204            .redirect(reqwest::redirect::Policy::custom(|attempt| {
205                let next = attempt.url();
206                if next.scheme() == "https" || is_loopback_url(next) {
207                    if attempt.previous().len() >= 10 {
208                        attempt.error("too many redirects")
209                    } else {
210                        attempt.follow()
211                    }
212                } else {
213                    attempt.stop()
214                }
215            }))
216            .build()
217            .map_err(|e| ChainViewError::Config(format!("build reqwest client: {e}")))?;
218        Ok(Self { base_url, client })
219    }
220}
221
222/// Construct the built-in Esplora chain view from the `KEEP_CHAIN_URL`
223/// environment variable, applying the responder's fail-closed policy: a
224/// missing or invalid endpoint yields a `REFUSED:` error rather than signing
225/// without an authoritative amount check. Both the CLI and desktop responder
226/// paths call this so their behavior and error messages stay identical.
227#[cfg(feature = "esplora-chain-view")]
228pub fn esplora_chain_view_from_env() -> Result<EsploraChainView, String> {
229    let chain_url = std::env::var(KEEP_CHAIN_URL_ENV).map_err(|_| {
230        format!(
231            "REFUSED: {KEEP_CHAIN_URL_ENV} is not set. Set it to an esplora / mempool.space \
232             endpoint (e.g. https://blockstream.info/api) so #502 prevout amount validation \
233             can run. Refusing to sign without an authoritative amount check."
234        )
235    })?;
236    EsploraChainView::new(&chain_url)
237        .map_err(|e| format!("REFUSED: invalid {KEEP_CHAIN_URL_ENV}={chain_url:?}: {e}"))
238}
239
240#[cfg(feature = "esplora-chain-view")]
241#[derive(serde::Deserialize)]
242struct EsploraVout {
243    value: u64,
244    scriptpubkey: String,
245}
246
247#[cfg(feature = "esplora-chain-view")]
248#[derive(serde::Deserialize)]
249struct EsploraTx {
250    txid: String,
251    vout: Vec<EsploraVout>,
252}
253
254#[cfg(feature = "esplora-chain-view")]
255impl ChainView for EsploraChainView {
256    fn get_prevout(&self, outpoint: OutPoint) -> Result<TxOut, ChainViewError> {
257        let path = format!("tx/{}", outpoint.txid);
258        let url = self
259            .base_url
260            .join(&path)
261            .map_err(|e| ChainViewError::Config(format!("join path {path}: {e}")))?;
262        let resp = self
263            .client
264            .get(url)
265            .send()
266            .map_err(|e| ChainViewError::Transport(e.to_string()))?;
267        if resp.status() == reqwest::StatusCode::NOT_FOUND {
268            return Err(ChainViewError::NotFound {
269                txid: outpoint.txid,
270                vout: outpoint.vout,
271            });
272        }
273        if !resp.status().is_success() {
274            return Err(ChainViewError::Transport(format!(
275                "HTTP {} from chain view",
276                resp.status()
277            )));
278        }
279        // Bound the response body: a single tx JSON is far smaller than 2 MiB,
280        // and an unbounded read lets a hostile/compromised endpoint exhaust
281        // memory on the signing host. Enforce the cap during the read via a
282        // limited reader so a chunked or content-length-lying response cannot
283        // buffer past the limit before we check it.
284        use std::io::Read as _;
285        const MAX_BODY: u64 = 2 * 1024 * 1024;
286        if let Some(len) = resp.content_length() {
287            if len > MAX_BODY {
288                return Err(ChainViewError::Decode(format!(
289                    "chain view response too large ({len} bytes > {MAX_BODY} cap)"
290                )));
291            }
292        }
293        // Read at most MAX_BODY + 1 bytes: the extra byte lets us detect an
294        // over-cap body without ever holding more than the cap plus one in
295        // memory, regardless of what the endpoint claimed in Content-Length.
296        let mut body = Vec::new();
297        resp.take(MAX_BODY + 1)
298            .read_to_end(&mut body)
299            .map_err(|e| ChainViewError::Transport(e.to_string()))?;
300        if body.len() as u64 > MAX_BODY {
301            return Err(ChainViewError::Decode(format!(
302                "chain view response exceeds {MAX_BODY} byte cap"
303            )));
304        }
305        let tx: EsploraTx = serde_json::from_slice(&body)
306            .map_err(|e| ChainViewError::Decode(format!("parse esplora tx: {e}")))?;
307        // Verify the endpoint returned the transaction we asked for; a
308        // redirecting / caching / compromised endpoint must not substitute a
309        // different tx's vout under our requested txid.
310        if !tx.txid.eq_ignore_ascii_case(&outpoint.txid.to_string()) {
311            return Err(ChainViewError::Decode(format!(
312                "chain view returned txid {} but {} was requested; refusing to trust a \
313                 substituted transaction.",
314                tx.txid, outpoint.txid,
315            )));
316        }
317        let vout_idx = outpoint.vout as usize;
318        let vout = tx.vout.get(vout_idx).ok_or(ChainViewError::NotFound {
319            txid: outpoint.txid,
320            vout: outpoint.vout,
321        })?;
322        let script_bytes = hex::decode(&vout.scriptpubkey)
323            .map_err(|e| ChainViewError::Decode(format!("decode scriptpubkey hex: {e}")))?;
324        Ok(TxOut {
325            value: bitcoin::Amount::from_sat(vout.value),
326            script_pubkey: bitcoin::ScriptBuf::from_bytes(script_bytes),
327        })
328    }
329}
330
331#[cfg(test)]
332mod tests {
333    use super::*;
334    use bitcoin::absolute::LockTime;
335    use bitcoin::transaction::Version;
336    use bitcoin::{Amount, ScriptBuf, Sequence, Transaction, TxIn, Txid, Witness};
337    use std::collections::HashMap;
338    use std::sync::Mutex;
339
340    /// Test-only in-memory chain view; maps outpoints to canned TxOuts.
341    struct MockChainView {
342        entries: Mutex<HashMap<OutPoint, TxOut>>,
343    }
344
345    impl MockChainView {
346        fn new() -> Self {
347            Self {
348                entries: Mutex::new(HashMap::new()),
349            }
350        }
351        fn insert(&self, op: OutPoint, out: TxOut) {
352            self.entries.lock().unwrap().insert(op, out);
353        }
354    }
355
356    impl ChainView for MockChainView {
357        fn get_prevout(&self, outpoint: OutPoint) -> Result<TxOut, ChainViewError> {
358            self.entries
359                .lock()
360                .unwrap()
361                .get(&outpoint)
362                .cloned()
363                .ok_or(ChainViewError::NotFound {
364                    txid: outpoint.txid,
365                    vout: outpoint.vout,
366                })
367        }
368    }
369
370    fn make_outpoint(nonce: u8) -> OutPoint {
371        OutPoint {
372            txid: Txid::from_raw_hash(bitcoin::hashes::Hash::hash(&[nonce])),
373            vout: 0,
374        }
375    }
376
377    fn make_psbt(inputs: Vec<(OutPoint, TxOut)>) -> Psbt {
378        let tx = Transaction {
379            version: Version::TWO,
380            lock_time: LockTime::ZERO,
381            input: inputs
382                .iter()
383                .map(|(op, _)| TxIn {
384                    previous_output: *op,
385                    script_sig: ScriptBuf::new(),
386                    sequence: Sequence::MAX,
387                    witness: Witness::new(),
388                })
389                .collect(),
390            output: vec![TxOut {
391                value: Amount::from_sat(500),
392                script_pubkey: ScriptBuf::new(),
393            }],
394        };
395        let mut psbt = Psbt::from_unsigned_tx(tx).unwrap();
396        for (idx, (_, prev)) in inputs.into_iter().enumerate() {
397            psbt.inputs[idx].witness_utxo = Some(prev);
398        }
399        psbt
400    }
401
402    fn taproot_script() -> ScriptBuf {
403        use bitcoin::secp256k1::{Secp256k1, SecretKey};
404        let secp = Secp256k1::new();
405        let sk = SecretKey::from_slice(&[0x22; 32]).unwrap();
406        let (xonly, _) = sk.x_only_public_key(&secp);
407        ScriptBuf::new_p2tr_tweaked(bitcoin::key::TweakedPublicKey::dangerous_assume_tweaked(
408            xonly,
409        ))
410    }
411
412    /// #502 happy path: PSBT amounts match chain view -> Ok.
413    #[test]
414    fn matching_witness_utxo_amount_verifies() {
415        let chain = MockChainView::new();
416        let op = make_outpoint(1);
417        let prev = TxOut {
418            value: Amount::from_sat(100_000),
419            script_pubkey: taproot_script(),
420        };
421        chain.insert(op, prev.clone());
422        let psbt = make_psbt(vec![(op, prev)]);
423        validate_prevout_amounts_against_chain(&psbt, &chain).unwrap();
424    }
425
426    /// #502 core: proposer understates the input amount, responder catches
427    /// the divergence and refuses. This is the exact attack the issue calls
428    /// out: an understated `witness_utxo.value` defeats every fee cap.
429    #[test]
430    fn understated_witness_utxo_amount_refuses() {
431        let chain = MockChainView::new();
432        let op = make_outpoint(2);
433        let real = TxOut {
434            value: Amount::from_sat(100_000),
435            script_pubkey: taproot_script(),
436        };
437        chain.insert(op, real);
438        let lied = TxOut {
439            value: Amount::from_sat(10_000),
440            script_pubkey: taproot_script(),
441        };
442        let psbt = make_psbt(vec![(op, lied)]);
443        let err = validate_prevout_amounts_against_chain(&psbt, &chain)
444            .expect_err("understated amount must be refused");
445        assert!(err.contains("amount mismatch"), "err was: {err}");
446    }
447
448    /// A PSBT input whose declared script does not match the chain view is
449    /// refused, catching a UTXO-substitution proposal.
450    #[test]
451    fn script_mismatch_refuses() {
452        let chain = MockChainView::new();
453        let op = make_outpoint(3);
454        let real = TxOut {
455            value: Amount::from_sat(100_000),
456            script_pubkey: taproot_script(),
457        };
458        chain.insert(op, real);
459        let claimed = TxOut {
460            value: Amount::from_sat(100_000),
461            script_pubkey: ScriptBuf::from_bytes(vec![0xAB, 0xCD]),
462        };
463        let psbt = make_psbt(vec![(op, claimed)]);
464        let err = validate_prevout_amounts_against_chain(&psbt, &chain)
465            .expect_err("script mismatch must be refused");
466        assert!(err.contains("script_pubkey mismatch"), "err was: {err}");
467    }
468
469    /// An input without witness_utxo cannot be validated; refuse rather
470    /// than silently pass or fall back to a claim of "unknown".
471    #[test]
472    fn missing_witness_utxo_refuses() {
473        let chain = MockChainView::new();
474        let op = make_outpoint(4);
475        let tx = Transaction {
476            version: Version::TWO,
477            lock_time: LockTime::ZERO,
478            input: vec![TxIn {
479                previous_output: op,
480                script_sig: ScriptBuf::new(),
481                sequence: Sequence::MAX,
482                witness: Witness::new(),
483            }],
484            output: vec![TxOut {
485                value: Amount::from_sat(500),
486                script_pubkey: ScriptBuf::new(),
487            }],
488        };
489        let psbt = Psbt::from_unsigned_tx(tx).unwrap();
490        let err = validate_prevout_amounts_against_chain(&psbt, &chain)
491            .expect_err("missing witness_utxo must be refused");
492        assert!(err.contains("witness_utxo"), "err was: {err}");
493    }
494
495    /// A chain-view transport error is refusal-worthy: an inconclusive read
496    /// MUST NOT be interpreted as "no divergence".
497    #[test]
498    fn transport_error_refuses() {
499        struct FailingChain;
500        impl ChainView for FailingChain {
501            fn get_prevout(&self, _: OutPoint) -> Result<TxOut, ChainViewError> {
502                Err(ChainViewError::Transport("simulated".into()))
503            }
504        }
505        let op = make_outpoint(5);
506        let claim = TxOut {
507            value: Amount::from_sat(100_000),
508            script_pubkey: taproot_script(),
509        };
510        let psbt = make_psbt(vec![(op, claim)]);
511        let err = validate_prevout_amounts_against_chain(&psbt, &FailingChain)
512            .expect_err("transport error must be refused");
513        assert!(err.contains("chain view"), "err was: {err}");
514    }
515
516    /// Empty PSBT is refused before any chain call is made.
517    #[test]
518    fn empty_psbt_refuses() {
519        let chain = MockChainView::new();
520        let tx = Transaction {
521            version: Version::TWO,
522            lock_time: LockTime::ZERO,
523            input: vec![],
524            output: vec![TxOut {
525                value: Amount::from_sat(500),
526                script_pubkey: ScriptBuf::new(),
527            }],
528        };
529        let psbt = Psbt::from_unsigned_tx(tx).unwrap();
530        assert!(validate_prevout_amounts_against_chain(&psbt, &chain).is_err());
531    }
532
533    /// A 2-input PSBT where only input[1] diverges is refused, guarding the
534    /// zip/enumerate loop against an off-by-one that would only check input[0].
535    #[test]
536    fn second_input_amount_divergence_refuses() {
537        let chain = MockChainView::new();
538        let op0 = make_outpoint(7);
539        let op1 = make_outpoint(8);
540        let real0 = TxOut {
541            value: Amount::from_sat(100_000),
542            script_pubkey: taproot_script(),
543        };
544        let real1 = TxOut {
545            value: Amount::from_sat(200_000),
546            script_pubkey: taproot_script(),
547        };
548        chain.insert(op0, real0.clone());
549        chain.insert(op1, real1);
550        let lied1 = TxOut {
551            value: Amount::from_sat(50_000),
552            script_pubkey: taproot_script(),
553        };
554        let psbt = make_psbt(vec![(op0, real0), (op1, lied1)]);
555        let err = validate_prevout_amounts_against_chain(&psbt, &chain)
556            .expect_err("input[1] divergence must be refused");
557        assert!(err.contains("amount mismatch"), "err was: {err}");
558        assert!(err.contains("input 1"), "should identify input 1: {err}");
559    }
560
561    /// A PSBT whose input-record count exceeds its unsigned-tx input count is
562    /// refused before any chain call, guarding the zip against a truncated walk.
563    #[test]
564    fn input_count_mismatch_refuses() {
565        let chain = MockChainView::new();
566        let op = make_outpoint(9);
567        let prev = TxOut {
568            value: Amount::from_sat(100_000),
569            script_pubkey: taproot_script(),
570        };
571        chain.insert(op, prev.clone());
572        let mut psbt = make_psbt(vec![(op, prev)]);
573        psbt.inputs.push(bitcoin::psbt::Input::default());
574        let err = validate_prevout_amounts_against_chain(&psbt, &chain)
575            .expect_err("input count mismatch must be refused");
576        assert!(
577            err.contains("does not match unsigned tx input count"),
578            "err was: {err}"
579        );
580    }
581
582    /// `EsploraChainView::new` normalizes with and without a trailing slash.
583    #[cfg(feature = "esplora-chain-view")]
584    #[test]
585    fn esplora_new_normalizes_trailing_slash() {
586        EsploraChainView::new("https://blockstream.info/api").expect("no trailing slash ok");
587        EsploraChainView::new("https://blockstream.info/api/").expect("trailing slash ok");
588    }
589
590    /// `EsploraChainView::new` refuses plaintext http except to loopback hosts.
591    #[cfg(feature = "esplora-chain-view")]
592    #[test]
593    fn esplora_new_enforces_https_except_loopback() {
594        assert!(
595            EsploraChainView::new("http://evil.example/api").is_err(),
596            "non-loopback http must be refused"
597        );
598        EsploraChainView::new("http://127.0.0.1:3000/api").expect("loopback http ok");
599    }
600}