Skip to content

Commit

Permalink
http: Alias /txs/since/0 as /txs
Browse files Browse the repository at this point in the history
  • Loading branch information
shesek committed Nov 14, 2020
1 parent 40ffe58 commit 63ae3e8
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@

- Shutdown cleanly, via `SIGINT`/`SIGTERM` for CLI or a custom signal for library users (#62, #66)

- Electrum: Fix `mempool.get_fee_histogram` (5af7bfc62d7d98)

- Renamed CLI options: `--http-server-addr` to `--http-addr`, `--electrum-rpc-addr` to `--electrum-addr`

- HTTP: Alias `GET /txs/since/0` as `GET /txs`

- Electrum: Fix `mempool.get_fee_histogram` (5af7bfc62d7d98)

- Upgrade to rust-bitcoin v0.25 and rust-bitcoincore-rpc v0.12

## 0.1.5 - 2020-10-05
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -631,18 +631,21 @@ $ curl localhost:3060/tx/1f2e3c4cee8ea127a79c5dbc951f1e005671a1e8bf385e791ff95b7

</details>

#### `GET /txs`
#### `GET /txs/since/:block-height`

Get all wallet transactions confirmed at or after `block-height`, plus all unconfirmed transactions,
for all tracked addresses.

`GET /txs` is an alias for `GET /txs/since/0`.

<details><summary>Expand...</summary><p></p>

Returned in the [wallet transaction format](#wallet-transaction-format). Sorted with oldest first.

Example:
```
$ curl localhost:3060/txs/since/0
$ curl localhost:3060/txs
[
{
"txid": "e700187477d262f370b4f1dfd17c496d108524ee2d440a0b7e476f66da872dda",
Expand Down
2 changes: 1 addition & 1 deletion contrib/nodejs-bwt-daemon/example.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const BwtDaemon = require('bwt-daemon')

console.log('wallets:', await bwt('wallets'))
console.log('address:', await bwt('wallet/qufmgwfu/10'))
console.log('transactions:', await bwt('txs/since/0'))
console.log('transactions:', await bwt('txs'))

setTimeout(_ => bwtd.shutdown(), 5000)
})()
8 changes: 7 additions & 1 deletion src/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,15 @@ fn setup(
})
.map(handle_error);

// GET /txs
// GET /txs/since/:block_height
let txs_since_handler = warp::get()
.and(warp::path!("txs" / "since" / u32))
.and(warp::path("txs"))
.and(
warp::path!("since" / u32)
.or(warp::path::end().map(|| 0))
.unify(),
)
.and(query.clone())
.map(|min_block_height: u32, query: Arc<Query>| {
let txs = query.map_history_since(min_block_height, |txhist| {
Expand Down

0 comments on commit 63ae3e8

Please sign in to comment.