Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Community curated plugins for c-lightning.
| [prometheus][prometheus] | Lightning node exporter for the prometheus timeseries server |
| [rebalance][rebalance] | Keeps your channels balanced |
| [reckless][reckless] | An **experimental** plugin manager (search/install plugins) |
| [sauron][sauron] | A Bitcoin backend relying on [Esplora][esplora]'s API |
| [sendinvoiceless][sendinvoiceless] | Sends some money without an invoice from the receiving node. |
| [sitzprobe][sitzprobe] | A Lightning Network payment rehearsal utility |
| [summary][summary] | Print a nice summary of the node status |
Expand Down Expand Up @@ -118,6 +119,7 @@ your environment.
- [C++ Plugin API & RPC Client][cpp-api] by @darosior
- [Javascript Plugin API & RPC Client][js-api] by @darosior

[esplora]: https://github.com/Blockstream/esplora
[pers-chans]: https://github.com/lightningd/plugins/tree/master/persistent-channels
[probe]: https://github.com/lightningd/plugins/tree/master/probe
[prometheus]: https://github.com/lightningd/plugins/tree/master/prometheus
Expand All @@ -140,6 +142,7 @@ your environment.
[js-api]: https://github.com/darosior/clightningjs
[monitor]: https://github.com/renepickhardt/plugins/tree/master/monitor
[reckless]: https://github.com/darosior/reckless
[sauron]: https://github.com/lightningd/plugins/tree/master/sauron
[zmq-home]: https://zeromq.org/
[zmq]: https://github.com/lightningd/plugins/tree/master/zmq
[csvexportpays]: https://github.com/0xB10C/c-lightning-plugin-csvexportpays
25 changes: 25 additions & 0 deletions sauron/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
## Sauron

A Bitcoin backend plugin relying on [Esplora](https://github.com/Blockstream/esplora).


### About

It allows C-lightning to run without needing a *local* `bitcoind`, and can be either
self-hosted (Esplora is Open Source, and self hosting it is basically a `docker` one-liner).

This is still a WIP, so is the API C-lightning side. So not to be used for real.


### Run

You need to:
- disable the default Bitcoin backend (`bcli`)
- register sauron
- provide the API endpoint you want to use

Here is a fully reptilian example running against [blockstream.info](https://blockstream.info/):

```
lightningd --mainnet --disable-plugin bcli --plugin $PWD/sauron.py --sauron-api-endpoint https://blockstream.info/api/
```
26 changes: 16 additions & 10 deletions sauron/sauron.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def getrawblock(plugin, height, **kwargs):
blockhash_url = "{}/block-height/{}".format(plugin.api_endpoint, height)

blockhash_req = requests.get(blockhash_url)
# FIXME: Esplora doesn't serve raw blocks !
# FIXME: Esplora now serves raw blocks, integrate it when deployed !
# https://github.com/Blockstream/esplora/issues/171
block_url = "https://blockchain.info/block/{}?format=hex"
block_req = requests.get(block_url.format(blockhash_req.text))
Expand Down Expand Up @@ -107,22 +107,28 @@ def getutxout(plugin, txid, vout, **kwargs):
}


@plugin.method("getfeerate")
def getfeerate(plugin, blocks, mode, **kwargs):
@plugin.method("estimatefees")
def getfeerate(plugin, **kwargs):
feerate_url = "{}/fee-estimates".format(plugin.api_endpoint)
# Use an estimation provided by esplora
if blocks == 100:
blocks = 144

feerate_req = requests.get(feerate_url)
assert feerate_req.status_code == 200
feerates = json.loads(feerate_req.text)
# It renders sat/vB, so * 10**8 / 10**3 for BTC/kB
feerate = feerates[str(blocks)] * 10**5
# It renders sat/vB, we want sat/kVB, so multiply everything by 10**3
slow = int(feerates["144"] * 10**3)
normal = int(feerates["5"] * 10**3)
urgent = int(feerates["3"] * 10**3)
very_urgent = int(feerates["2"] * 10**3)

# FIXME mode ?
return {
"feerate": int(feerate),
"opening": normal,
"mutual_close": normal,
"unilateral_close": very_urgent,
"delayed_to_us": normal,
"htlc_resolution": urgent,
"penalty": urgent,
"min_acceptable": slow // 2,
"max_acceptable": very_urgent * 10,
}


Expand Down