forked from bitcoin-dev-project/warnet
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ln: open rest api and ensure scenarios can open channels
- Loading branch information
Showing
6 changed files
with
133 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import json | ||
|
||
from commander import Commander | ||
|
||
|
||
class LNBasic(Commander): | ||
def set_test_params(self): | ||
self.num_nodes = None | ||
|
||
def add_options(self, parser): | ||
parser.description = "Open a channel between two LN nodes using REST + macaroon" | ||
parser.usage = "warnet run /path/to/ln_init.py" | ||
|
||
def run_test(self): | ||
info = json.loads(self.tanks["tank-0003"].lnd.get("/v1/getinfo")) | ||
uri = info["uris"][0] | ||
pk3, host = uri.split("@") | ||
|
||
print( | ||
self.tanks["tank-0002"].lnd.post( | ||
"/v1/peers", data={"addr": {"pubkey": pk3, "host": host}} | ||
) | ||
) | ||
|
||
print( | ||
self.tanks["tank-0002"].lnd.post( | ||
"/v1/channels/stream", | ||
data={"local_funding_amount": 100000, "node_pubkey": self.hex_to_b64(pk3)}, | ||
) | ||
) | ||
|
||
# Mine it ourself | ||
self.wait_until(lambda: self.tanks["tank-0002"].getmempoolinfo()["size"] == 1) | ||
print(self.tanks["tank-0002"].generate(5, invalid_call=False)) | ||
|
||
|
||
def main(): | ||
LNBasic().main() | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters