Skip to content

Commit

Permalink
Update requirements.txt and README.md for use with mutinynet
Browse files Browse the repository at this point in the history
  • Loading branch information
ca-ruz committed Sep 24, 2024
1 parent b8ca105 commit 70dc8ad
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
8 changes: 8 additions & 0 deletions sauron/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ Here is a fully reptilian example running against [blockstream.info](https://blo
lightningd --mainnet --disable-plugin bcli --plugin $PWD/sauron.py --sauron-api-endpoint https://blockstream.info/api/
```


Here is an example running against [mutinynet.com](https://mutinynet.com/):

```
lightningd --signet --disable-plugin bcli --plugin $PWD/sauron.py --sauron-api-endpoint https://mutinynet.com/api/
```


You can use also proxy your requests through [Tor](https://www.torproject.org/) by
specifying a SOCKS proxy to use with the `--sauron-tor-proxy` startup option, in
the form `address:port`.
Expand Down
2 changes: 1 addition & 1 deletion sauron/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
pyln-client>=23.2
pyln-client==24.5
requests[socks]>=2.23.0
7 changes: 6 additions & 1 deletion sauron/sauron.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class SauronError(Exception):
pass

def fetch(url):
"""Fetch this {url}, maybe through a pre-defined proxy."""
"""Fetch the given {url}, maybe through a pre-defined proxy."""
# FIXME: Maybe try to be smart and renew circuit to broadcast different
# transactions ? Hint: lightningd will agressively send us the same
# transaction a certain amount of times.
Expand Down Expand Up @@ -79,6 +79,7 @@ def init(plugin, options, **kwargs):
def getchaininfo(plugin, **kwargs):
blockhash_url = "{}/block-height/0".format(plugin.api_endpoint)
blockcount_url = "{}/blocks/tip/height".format(plugin.api_endpoint)

chains = {
"000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f": "main",
"000000000933ea01ad0ee984209779baaec3ced90fa3f408719526f8d77f4943": "test",
Expand Down Expand Up @@ -117,7 +118,9 @@ def getchaininfo(plugin, **kwargs):

@plugin.method("getrawblockbyheight")
def getrawblock(plugin, height, **kwargs):
# Step 1: Get the block hash by height
blockhash_url = "{}/block-height/{}".format(plugin.api_endpoint, height)

blockhash_req = fetch(blockhash_url)
if blockhash_req.status_code != 200:
return {
Expand Down Expand Up @@ -278,6 +281,7 @@ def estimatefees(plugin, **kwargs):
{"blocks": 144, "feerate": slow}
]

# Return the estimated fees
return {
"opening": normal,
"mutual_close": normal,
Expand All @@ -295,6 +299,7 @@ def estimatefees(plugin, **kwargs):
"sauron-api-endpoint",
"",
"The URL of the esplora instance to hit (including '/api').",
"The URL of the mutinynet instance to hit (including '/api').",
)

plugin.add_option(
Expand Down

0 comments on commit 70dc8ad

Please sign in to comment.