{"id":39016654,"url":"https://github.com/joakimofv/lntransport","last_synced_at":"2026-01-17T17:25:23.191Z","repository":{"id":43574320,"uuid":"501221535","full_name":"joakimofv/lntransport","owner":"joakimofv","description":"Dial and listen for Bitcoin Lightning Network (LN) connections. Context aware send and receive.","archived":false,"fork":false,"pushed_at":"2022-08-08T09:25:22.000Z","size":66,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2023-07-27T22:15:35.432Z","etag":null,"topics":["bitcoin","encryption-decryption","go","golang","library","lightning-network","networking"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/joakimofv.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-06-08T11:28:30.000Z","updated_at":"2022-07-29T12:15:07.000Z","dependencies_parsed_at":"2022-08-24T14:36:50.051Z","dependency_job_id":null,"html_url":"https://github.com/joakimofv/lntransport","commit_stats":null,"previous_names":[],"tags_count":5,"template":null,"template_full_name":null,"purl":"pkg:github/joakimofv/lntransport","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joakimofv%2Flntransport","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joakimofv%2Flntransport/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joakimofv%2Flntransport/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joakimofv%2Flntransport/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/joakimofv","download_url":"https://codeload.github.com/joakimofv/lntransport/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joakimofv%2Flntransport/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28512902,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-17T13:38:16.342Z","status":"ssl_error","status_checked_at":"2026-01-17T13:37:44.060Z","response_time":85,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bitcoin","encryption-decryption","go","golang","library","lightning-network","networking"],"created_at":"2026-01-17T17:25:23.095Z","updated_at":"2026-01-17T17:25:23.166Z","avatar_url":"https://github.com/joakimofv.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Go Reference](https://pkg.go.dev/badge/github.com/joakimofv/lntransport.svg)](https://pkg.go.dev/github.com/joakimofv/lntransport)\n\nlntransport\n===========\n\nAn object that can dial and listen for Bitcoin Lightning Network (LN) connections.\nThe connection objects send/receive messages with a simple API that uses context.Context.\n\nAll is safe for concurrent use.\n\n# Import\n\n```go\n\tlntransport \"github.com/joakimofv/lntransport\"\n```\n\n# Usage\n\n### [New](https://pkg.go.dev/github.com/joakimofv/lntransport#New)\n\n```go\ncfg := lntransport.Config{}\ncopy(cfg.Privkey[:], privkeyByteSlice)\nlt, err := lntransport.New(cfg)\nif err != nil {\n\t// Handle err.\n}\ndefer lt.Close()\n```\n\nPrivkey is a `[32]byte` array that needs to be a valid cryptographic key.\nSee [`Config`](https://pkg.go.dev/github.com/joakimofv/lntransport#Config).\n\n### [Listen](https://pkg.go.dev/github.com/joakimofv/lntransport#LnTransport.Listen)\n\n```go\nch, addr, err := lt.Listen(ctx, \"127.0.0.1:12345\")\n```\n\nCancelling the `ctx` will abort the background listening process.\n\nIncoming connections will be passed on the `ch` channel.\nThe channel will be closed when the listener is done so you can drain it like this:\n\n```go\nvar conn *Conn\nfor conn = range ch {\n\tdefer conn.Close()\n\t// ...\n}\n```\n\n### [Dial](https://pkg.go.dev/github.com/joakimofv/lntransport#LnTransport.Dial)\n\n```go\nconn, err := lt.Dial(ctx, \"1.2.3.4:12345\", remotePubkey)\nif err != nil {\n\t// Handle err.\n}\ndefer conn.Close()\n```\n\nThe `remotePubkey` refers to the pubkey of the remote side, a byte slice, which you have to learn somehow before dialing.\nFor your own side you can get it with `lt.Pubkey()`.\n\n### [Send](https://pkg.go.dev/github.com/joakimofv/lntransport#Conn.Send)\n\n```go\nerr := conn.Send(ctx, []byte(\"abcd...\"))\nif err != nil {\n\tif conn.IsClosed() {\n\t\t// conn has become defunct.\n\t}\n\t// Handle err.\n}\n```\n\n### [Receive](https://pkg.go.dev/github.com/joakimofv/lntransport#Conn.Receive)\n\n```go\nmsg, err := conn.Receive(ctx)\nif err != nil {\n\tif conn.IsClosed() {\n\t\t// conn has become defunct.\n\t}\n\t// Handle err.\n}\n```\n\n# Error Handling\n\n## Defunct Connection\n\nVarious network problems, counterparty problems, or bungled sends/receives may cause a connection object to become defunct.\nThen it will close itself. Check if it has happened with [`conn.IsClosed()`](https://pkg.go.dev/github.com/joakimofv/lntransport#Conn.IsClosed).\n\nA closed connection can not be recovered. Be ready to dial again to make a new connection, or handle the situation in some other way.\n\n## Failed Incoming Connection Attempts\n\nIncoming connection attempts to a listener may fail. By default, when it happens a line will be printed with stdlib `log`.\nAdjust what is done with these errors through fields in the [`Config`](https://pkg.go.dev/github.com/joakimofv/lntransport#Config).\n\n## Limit On Number Of Connections\n\nHaving more than 30 000 connection object active from a single LnTransport can cause it to malfunction. Avoid that.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoakimofv%2Flntransport","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoakimofv%2Flntransport","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoakimofv%2Flntransport/lists"}