Commit Graph

164 Commits

Author SHA1 Message Date
Steve Myers
898f230081
Merge bitcoindevkit/rust-electrum-client#126: Bump version to 0.19.0 and add CHANGELOG.md
Some checks failed
CI / Test (push) Has been cancelled
ef9fd6bf50 Bump version to 0.19.0 and add CHANGELOG.md (Steve Myers)

Pull request description:

  Besides bumping the version I've also added a simple changelog that list the PRs in this (0.19.0) and the prior (0.18.0) release. The main reason for this release is the bump of the rust-bitcoin version to 0.31.0 which is needed to upgrade dependent projects like bdk to also use rust-bitcoin 0.31.0.

ACKs for top commit:
  evanlinjin:
    ACK ef9fd6bf50

Tree-SHA512: c18a0312915adfad40ef900ac4f1ee10454863f7a29882f1fa8f967f4c13df34b4e3929703614d0c3e6b8a189338f3a4d15b8d4598f68b87948454184fb13957
2023-12-19 08:38:16 -06:00
Steve Myers
ef9fd6bf50
Bump version to 0.19.0 and add CHANGELOG.md 2023-12-11 21:18:21 -06:00
Steve Myers
fd81717f8e
Merge bitcoindevkit/rust-electrum-client#125: enforce timeout on initial socks5 proxy connection
d8554fb550 enforce timeout on initial socks5 proxy connection (conduition)

Pull request description:

  This PR fixes a bug which excepted initial SOCKS5 proxy connection attempts from the punctual enforcement of timeouts.

  Before this change, invoking `Socks5Stream::connect` (or `Socks5Stream::connect_with_password`) could block for much longer than the configured timeout. In practice, this manifested as `Client::from_config` apparently failing to respect the timeout specified in the `Config` passed to it. AFAICT this only applied to SOCKS proxy connections.

  ## Example

  To demonstrate, here is a simple example program which attempts to connect to an unreachable electrum server with a 10 second timeout.
  ```rust
  use electrum_client::{Client, ConfigBuilder, Socks5Config};

  fn main() {
      let proxy = Socks5Config::new("127.0.0.1:9050");
      let config = ConfigBuilder::new()
          .socks5(Some(proxy))
          .timeout(Some(10))
          .build();

      let start = std::time::SystemTime::now();
      let result = Client::from_config(
          "tcp://bejqtnc64qttdempkczylydg7l3ordwugbdar7yqbndck53ukx7wnwad.onion:50001",
          config,
      );
      match result {
          Ok(_) => {
              println!("Successfully connected")
          }
          Err(e) => {
              println!(
                  "failed to connect after {:.2}s: {e}",
                  start.elapsed().unwrap().as_secs_f64()
              );
          }
      };
  }
  ```

  You'd expect the connection attempt to always fail at around 10 seconds, but in fact most attempts take considerably longer.

  ```
  $ for i in {1..10} ; do cargo run -q ; done
  failed to connect after 7.65s: host unreachable
  failed to connect after 47.78s: host unreachable
  failed to connect after 18.17s: host unreachable
  failed to connect after 29.24s: host unreachable
  failed to connect after 16.15s: host unreachable
  failed to connect after 14.40s: host unreachable
  failed to connect after 16.89s: host unreachable
  failed to connect after 9.93s: host unreachable
  failed to connect after 8.81s: host unreachable
  failed to connect after 17.80s: host unreachable
  ```

  ## Cause and Fix

  This was happening because the private method `Socks5Stream::connect_raw` [only respected the `timeout` parameter for _the initial connection to the proxy address_](5ecb26fd7d/src/socks/v5.rs (L200-L205)).

  Once that TCP socket is established, the SOCKS5 client code must exchange a couple of messages with the proxy itself: One request/response cycle to authenticate, and then another request/response cycle to configure the forward proxy to the ultimate destination address. The latter of these two request/response cycles could block for long periods of time, in the case where the proxy was responsive but the ultimate destination was unresponsive.

  Since no timeout was set on the socket at this stage, the `Socks5Stream` code would wait for an indefinite amount of time for a reply from the proxy, usually only once the proxy itself times out and finally sends a reply.

  My suggested fix in this PR is to set the read/write timeouts immediately on the socket connecting to the proxy, so that if the proxy doesn't reply in time, we return an error to the caller promptly.

ACKs for top commit:
  RCasatta:
    utACK d8554fb550

Tree-SHA512: 4bc0ca203465c0d9722680de7251ee49dbea6d5a2b2a833a1ed42e792342a7ac977ad72649603caacd3e58d233b1a516af1ad40c6935addb8165b720d823cf42
2023-12-08 16:11:00 -06:00
conduition
d8554fb550
enforce timeout on initial socks5 proxy connection 2023-12-07 19:05:00 +00:00
Steve Myers
91228df8a5
Merge bitcoindevkit/rust-electrum-client#121: Upgrade bitcoin
dd3c171a7a Upgrade bitcoin (Tobin C. Harding)

Pull request description:

  Upgrade bitcoin dependency to `rust-bitcoin v0.31.0-rc1`:

  Allows us to remove the dependency on `bitcoin-private` because the `hex` stuff is exposed by `bitcoin` now.

ACKs for top commit:
  notmandatory:
    ACK dd3c171a7a

Tree-SHA512: 9082d3c2136445230bb23669f83fed58c90d1baf28d35527fc3dea1d40c9d3bdebeddbc44b3bdbc8e79c9b701e09cb453c018af0bc4ac8bcd1c4a14d11c90e39
2023-12-07 11:27:10 -06:00
Tobin C. Harding
dd3c171a7a
Upgrade bitcoin
Upgrade bitcoin dependency to `rust-bitcoin v0.31.0`:

Allows us to remove the dependency on `bitcoin-private` because the
`hex` stuff is exposed by `bitcoin` now.
2023-12-07 17:16:46 +11:00
Steve Myers
e4d2b1d194
Merge bitcoindevkit/rust-electrum-client#122: Add utility to validate GetMerkleRes
54fd52d898 Add test coverage for `validate_merkle_proof` (Elias Rohrer)
fe33e19bda Add utility for validating a Merkle inclusion proof (Elias Rohrer)
dd872d6714 Make response types `Clone` (Elias Rohrer)

Pull request description:

  I recently needed to validate a Merkle inclusion proof as retrieved via `transaction_get_merkle`.

  As I figured it might be useful to other people, too, we add it here as a simple utility method.

ACKs for top commit:
  notmandatory:
    ACK 54fd52d898

Tree-SHA512: aac12160d5b91a011988f45013eb92924c2dfb244c1720e73dc5bcb731e69065c38e022502c756100d8ee6c9af06efa0de9bbfbb2b9e3c2e34d3223539206e1c
2023-12-06 22:55:03 -06:00
Steve Myers
dacd772d5e
Merge bitcoindevkit/rust-electrum-client#117: Remove webpki and bump webpki-roots to v0.25
a331ae8059 Remove `webpki` and bump `webpki-roots` to `v0.25` (Yuki Kishimoto)

Pull request description:

  I noticed that `webpki` dependency is no longer maintained and that has a high severity vulnerability.
  This PR remove the `webpki` dependency and bump `webpki-roots` to v0.25

ACKs for top commit:
  notmandatory:
    ACK a331ae8059

Tree-SHA512: 63e9498dc0d56a07e7dd09dd43ca9a924d7e9ebb09934f2c762e64c9ce163cd58edb4d1563db4eba18a0fdf22642cb7d801940baeb97b6ce5473970b739278d4
2023-12-06 22:53:02 -06:00
Steve Myers
8b31e5fe41
Merge bitcoindevkit/rust-electrum-client#94: Add Batch::raw and improve docs
adb0c7444e Add `Batch::raw` and improve docs (志宇)

Pull request description:

  Being able to add raw requests to `Batch` makes sense from an API standpoint because we already allow raw non-batched requests. This is also useful when the electrum server API gets an updated version and our client is unable to keep up.

  Additional to this, I have improved the documentation and made `Call` private (since `Call` is never used externally).

ACKs for top commit:
  notmandatory:
    ACK adb0c7444e

Tree-SHA512: 808dccf1152b750881e45a9709fb4127835ecff3da5ecccffcb9f03e62171192c58154860195db7d3d3467ae8e3e450bba845ff4e8d4dffb302c3d8d6eb837fd
2023-12-06 22:45:25 -06:00
Elias Rohrer
54fd52d898
Add test coverage for validate_merkle_proof 2023-11-10 09:51:04 +01:00
Elias Rohrer
fe33e19bda
Add utility for validating a Merkle inclusion proof
... as retrieved via `transaction_get_merkle`.
2023-11-10 09:51:04 +01:00
Elias Rohrer
dd872d6714
Make response types Clone
.. as it's convenient.
2023-10-27 16:32:51 +02:00
Yuki Kishimoto
a331ae8059
Remove webpki and bump webpki-roots to v0.25 2023-08-25 12:17:38 +02:00
Daniela Brozzoni
5ecb26fd7d
Merge bitcoindevkit/rust-electrum-client#116: Bump to version 0.18
3f6dd0c796 Bump to version 0.18 (Daniela Brozzoni)

Pull request description:

ACKs for top commit:
  RCasatta:
    ACK 3f6dd0c796

Tree-SHA512: f42f2008d79b9a0334c375652842fb2745d2481422a24f27dd4e350bcc17e47f0da2888545a344e1438ede288ed2ad0de8b359b87004fbe059f310aad886c60a
2023-08-05 21:28:48 +02:00
Daniela Brozzoni
3f6dd0c796
Bump to version 0.18
Some checks failed
CI / Test (push) Has been cancelled
2023-08-03 15:48:20 +02:00
Daniela Brozzoni
ed9bb09d02
Merge bitcoindevkit/rust-electrum-client#115: Revert "errors if expecing headers notification but not subscribed"
2d44350b44 Revert "errors if expecing headers notification but not subscribed" (Riccardo Casatta)

Pull request description:

  This reverts commit b86f2bb22c.

  Some errors started to happen in downstream tests after this commit

  #114

ACKs for top commit:
  danielabrozzoni:
    utACK 2d44350b44

Tree-SHA512: d31174055f4245cc9d99f336b166a44271067b8daecaf2bb55d507ecfa4eb557b9802d576742fba59fd4dfda3f45fc76f02d7896af31353f19fc3a38698ac5a2
2023-08-03 12:28:07 +02:00
Riccardo Casatta
2d44350b44
Revert "errors if expecing headers notification but not subscribed"
This reverts commit b86f2bb22c.

Some errors started to happen in downstream tests after this commit
2023-07-21 15:34:12 +02:00
Daniela Brozzoni
84b1435df5
Merge bitcoindevkit/rust-electrum-client#111: Bump to v0.17.0
7535debbd6 Bump to v0.17.0 (Daniela Brozzoni)

Pull request description:

ACKs for top commit:
  danielabrozzoni:
    self-ACK 7535debbd6

Tree-SHA512: 92292e6d93fcd79fd542b4153cd7689050525bb3834a556cd8e9604307f13ebb4e7012c7c4c9aee0a744046fbf9646e3b05eb93770c49b8252de7f7f2c5debbd
2023-07-13 18:51:19 -06:00
Daniela Brozzoni
7535debbd6
Bump to v0.17.0
Some checks failed
CI / Test (push) Has been cancelled
2023-07-13 18:49:46 -06:00
Daniela Brozzoni
87348e5809
Merge bitcoindevkit/rust-electrum-client#112: Ignore other unrecoverable errors in retry client
7c11f208c0 Ignore other unrecoverable errors in retry client (Riccardo Casatta)
dbec56a95b tests: fix list_unspent tests (Riccardo Casatta)

Pull request description:

  similar to https://github.com/bitcoindevkit/rust-electrum-client/pull/107

ACKs for top commit:
  danielabrozzoni:
    utACK 7c11f208c0

Tree-SHA512: 74768e197b754dd98bbd435abaa5bbea018e65103615fba0b874252202c59fee5ec07ca90c0a19e112d3a1351e7ac172bef3bdff2eb97d245eb981c2a58660f9
2023-07-13 18:48:06 -06:00
Riccardo Casatta
7c11f208c0
Ignore other unrecoverable errors in retry client 2023-07-13 09:31:24 +02:00
Riccardo Casatta
dbec56a95b
tests: fix list_unspent tests
the mtgox address used got too many txs, resulting in a server error:
"too many txs"

The address is changed with the peter todd sha256 breaking challenge, which
should be very difficult to spend :) and as of now has just a few txs
2023-07-13 09:31:21 +02:00
Daniela Brozzoni
20493aa475
Merge bitcoindevkit/rust-electrum-client#110: Update rustls dependency
f5a438cd0a Bump version to 0.16.0 (Tobin C. Harding)
9a7cc14c94 Update rustls dependency to version 0.21 (Tobin C. Harding)

Pull request description:

  Update the `rustls` dependency to version 0.21 and bump the version of this crate to 0.16 so the change can be released.

  I don't know what stage in your release cycle you guys are up to so I put the version bump as a separate patch - can drop it if not needed.

  Done to help with https://github.com/bitcoindevkit/rust-esplora-client/pull/51

ACKs for top commit:
  danielabrozzoni:
    utACK f5a438cd0a

Tree-SHA512: 106cbe57651a6e1365f87836598cbec9b1e837f0376ddc1c56cb75e5615543659f5c05cea7d5eb8da8b6cf278fcbe6ef866a019b9829db40cc8055798eb0f541
2023-06-28 09:46:12 +02:00
Tobin C. Harding
f5a438cd0a
Bump version to 0.16.0
Some checks failed
CI / Test (push) Has been cancelled
We just updated the rustls dependency, in order for downstream crates to
take advantage of this change bump the version so we can release.
2023-06-28 07:57:25 +10:00
Tobin C. Harding
9a7cc14c94
Update rustls dependency to version 0.21
Update to the latest version of `rustls`.
2023-06-28 07:56:21 +10:00
Daniela Brozzoni
c84507e45b
Merge bitcoindevkit/rust-electrum-client#109: Errors if expecting headers notification but not subscribed
b86f2bb22c errors if expecing headers notification but not subscribed (Riccardo Casatta)

Pull request description:

  the opposite, erroring when subscribing multiple times, is not handled because clients could call multiple times to trigger the server to reply with the tip

ACKs for top commit:
  danielabrozzoni:
    utACK b86f2bb22c - changes look good to me, didn't test locally

Tree-SHA512: e1a21223448e708cc054271eb1ac5285dc98bdadf7497a856fc4a19ff51655879352ca6ef9f3fb5ec5f9071dd7ee50b2e44d4c65e70694e5d9fa53d280179dd2
2023-06-27 15:12:08 +02:00
Riccardo Casatta
b86f2bb22c
errors if expecing headers notification but not subscribed
the opposite, erroring when subscribing multiple times, is not handled because
clients could call multiple times to trigger the server to reply with the tip
2023-06-20 15:45:11 +02:00
Daniela Brozzoni
d2dbab93be
Merge bitcoindevkit/rust-electrum-client#108: Bump to v0.15.1
0f356ef94d Bump to v0.15.1 (Alekos Filini)

Pull request description:

  Release as a bug fix with #107 merged

ACKs for top commit:
  danielabrozzoni:
    ACK 0f356ef94d

Tree-SHA512: 3da6a4701707549d62cfa936f5c185eec0967766797dfbacce1fb68b716b90f7e7e163c797dfb7792435cad2769a43e1b23247b0ec86f9a098a79ea4589ee281
2023-05-16 17:49:47 +02:00
Alekos Filini
0f356ef94d
Bump to v0.15.1
Some checks failed
CI / Test (push) Has been cancelled
2023-05-14 12:57:11 +02:00
Alekos Filini
27eb4d0cb0
Merge bitcoindevkit/rust-electrum-client#107: Retry client should return AlreadySubscribed error
3a61037733 Retry client should return AlreadySubscribed error (Riccardo Casatta)

Pull request description:

  Users may leverage the Error to avoid remembering client-side the subscription status. eg. Always subscribing and calling script_pop in case AlreadySubscribed is returned.

  Backport for version 0.14.0

ACKs for top commit:
  afilini:
    ACK 3a61037733

Tree-SHA512: d6542227ca03b9f3755cec05115f86de54789cfc49fc87b603b653e0458f6b03ae9fea57fa110221395a4e33cf62a5b2bd7639c4269ae5291e4c92c99ef41eba
2023-05-14 12:56:43 +02:00
Riccardo Casatta
3a61037733
Retry client should return AlreadySubscribed error
Users may leverage the Error to avoid remembering client-side the subscription
status. eg. Always subscribing and calling script_pop in case AlreadySubscribed
is returned.
2023-05-12 11:24:10 +02:00
Daniela Brozzoni
d8ee94c30d
Merge bitcoindevkit/rust-electrum-client#105: Bump to v0.15.0
bd16116f9a Bump to v0.15.0 (Alekos Filini)

Pull request description:

ACKs for top commit:
  danielabrozzoni:
    ACK bd16116f9a

Tree-SHA512: c184fe6ed2f2b3ad5282b4ddb2d3186dcadee4685a417ebff0f9ab9e1c9a5596d91dc561c831ae7131fc63a0401f4dc29ece30024c09e11b99683f613e8ed856
2023-05-02 20:30:53 +02:00
Alekos Filini
bd16116f9a
Bump to v0.15.0
Some checks failed
CI / Test (push) Has been cancelled
2023-05-02 20:27:00 +02:00
Daniela Brozzoni
b989ddb04b
Merge bitcoindevkit/rust-electrum-client#103: upgrade bitcoin dep to 0.30.0
c925a9179e upgrade bitcoin dep to 0.30.0 (Riccardo Casatta)

Pull request description:

ACKs for top commit:
  danielabrozzoni:
    ACK c925a9179e

Tree-SHA512: 2b9b7756639af4d931213046866dc36ebee2a5adcbd01c906e27990696b07f1bcf87c2ee009a959f96b17407637801b856e8d4fb9a933fab148f22a619a0d586
2023-05-02 20:18:14 +02:00
Riccardo Casatta
c925a9179e
upgrade bitcoin dep to 0.30.0 2023-04-06 11:50:13 +02:00
Alekos Filini
abdbd020e1
Bump to v0.14.0
Some checks failed
CI / Test (push) Has been cancelled
2023-04-06 10:11:18 +02:00
Alekos Filini
a04a84299d
Merge bitcoindevkit/rust-electrum-client#101: Make ScriptStatus Serializable
80b2adeb4b Make ScriptStatus Serializable (Riccardo Casatta)

Pull request description:

  it's common to cache this value client side, so making it Serializable simplify things downstream

ACKs for top commit:
  afilini:
    ACK 80b2adeb4b

Tree-SHA512: 9467b4f2ee24ee2a684931df31607135f44c624f65d7d3ee64b3991a06de73a07475e4d1a4b8062093500e6a7cb47c1b2ebf094596fca33bf4cc54b26851b910
2023-04-06 10:09:38 +02:00
Alekos Filini
d26dfd7f54
Merge bitcoindevkit/rust-electrum-client#100: Implement batch call for script subscribe
40cecd5010 Use Borrow for all items in IntoIterator (Riccardo Casatta)
bf2f8ef2e5 script_subscribe IntoIterator accepts Borrow<&Script> (Riccardo Casatta)
156e6fc839 Implement batch call for script subscribe (Riccardo Casatta)

Pull request description:

  script_subscribe call hasn't the batch counterpart which may be convenient for multiple subsequent subscribe.

ACKs for top commit:
  afilini:
    ACK 40cecd5010

Tree-SHA512: 26a3ebb9d1267a224c85b765cf793523771bf7e74990dd804a35693bfebc549f7524214725092eac2276f22cd24eafc72270986549ac02f52641db83fcb71324
2023-04-06 10:07:20 +02:00
Riccardo Casatta
80b2adeb4b
Make ScriptStatus Serializable
it's common to cache this value client side, so making it Serializable
simplify things downstream
2023-04-05 11:34:23 +02:00
Riccardo Casatta
40cecd5010
Use Borrow for all items in IntoIterator 2023-03-22 17:05:02 +01:00
Riccardo Casatta
bf2f8ef2e5
script_subscribe IntoIterator accepts Borrow<&Script>
So that is callable with `&Vec<Script>` and `Vec<&Script>`
2023-03-22 15:53:02 +01:00
Riccardo Casatta
156e6fc839
Implement batch call for script subscribe 2023-03-21 17:03:19 +01:00
Alekos Filini
84d6860144
Bump to v0.13.0
Some checks failed
CI / Test (push) Has been cancelled
2023-03-11 11:41:19 +01:00
Daniela Brozzoni
413c964e5c
Merge bitcoindevkit/rust-electrum-client#97: Don't .unwrap() on invalid proxies
3568b60612 Don't `.unwrap()` on invalid proxies (Riccardo Mazzarini)

Pull request description:

ACKs for top commit:
  danielabrozzoni:
    utACK 3568b60612

Tree-SHA512: c2ebb21d6e78616f34a8d3becb68551a857c7b391c46ff4d1e379e482a5a5d90a3c12807896fc4da99a7442b1911bf00f02db41ba0cb890bf0acd284b1e6e3e2
2023-02-27 09:18:05 +01:00
Riccardo Mazzarini
3568b60612
Don't .unwrap() on invalid proxies 2023-02-23 03:15:26 +01:00
志宇
adb0c7444e
Add Batch::raw and improve docs
Being able to add raw requests to `Batch` makes sense from an API
standpoint because we already allow raw non-batched requests. This is
also useful when the electrum server API gets an updated version and our
client is unable to keep up.

Additional to this, I have improved the documentation and made `Call`
private (since `Call` is never used externally).
2023-02-14 14:16:07 +13:00
Alekos Filini
129081999c
Merge bitcoindevkit/rust-electrum-client#88: timeout() and socks() don't return Result
561db261d3 `timeout()` and `socks()` don't return Result (Riccardo Casatta)

Pull request description:

  The `Result` was necessary in the past because they couldn't both be set,
  this is not true anymore after 7493630ed8

ACKs for top commit:
  afilini:
    ACK 561db261d3

Tree-SHA512: 7654cfbbc7beac6acec786060e373bbc046e1dae0faf2b2ca1df33121e9e92a8f4950c7f8775e44226a62483aeae41c76162cf037ce38137c44d2fedd38560c8
2022-09-13 18:36:59 +02:00
Riccardo Casatta
561db261d3
timeout() and socks() don't return Result
The `Result` was necessary in the past because they couldn't both be set,
this is not true anymore after 7493630ed8
2022-09-13 09:27:03 +02:00
Alekos Filini
add1b7853e
Merge bitcoindevkit/rust-electrum-client#87: Bump version to 0.12.0
97e60bad4b Bump version to 0.12.0 (Alekos Filini)

Pull request description:

ACKs for top commit:
  danielabrozzoni:
    ACK 97e60bad4b

Tree-SHA512: e71c2093229552b5317f9309008924a6b2e8f6a48564535d2cd77e6830f342359574518836cfa579460b642c6aa8a2f36b81637b2ee8a48a68f695425333f1a2
2022-09-05 11:53:22 +02:00
Alekos Filini
97e60bad4b
Bump version to 0.12.0
Some checks failed
CI / Test (push) Has been cancelled
2022-09-05 11:31:47 +02:00