├── .custom-gcl.yml ├── .editorconfig ├── .github ├── CODEOWNERS-HINT ├── ISSUE_TEMPLATE │ ├── bug_report.md │ ├── config.yml │ └── feature_request.md ├── actions │ ├── rebase │ │ └── action.yml │ └── setup-go │ │ └── action.yml ├── pull_request_template.md └── workflows │ ├── docker.yml │ ├── main.yml │ ├── release.yaml │ └── stats.yml ├── .gitignore ├── .golangci.yml ├── .protolint.yaml ├── .vscode └── settings.json ├── Dockerfile ├── LICENSE ├── Makefile ├── README.md ├── SECURITY.md ├── accessman.go ├── accessman_test.go ├── aezeed ├── README.md ├── bench_test.go ├── cipherseed.go ├── cipherseed_integration.go ├── cipherseed_test.go ├── errors.go └── wordlist.go ├── aliasmgr ├── aliasmgr.go └── aliasmgr_test.go ├── amp ├── child.go ├── derivation_test.go ├── shard_tracker.go ├── shard_tracker_test.go └── sharer.go ├── autopilot ├── agent.go ├── agent_constraints.go ├── agent_constraints_test.go ├── agent_test.go ├── betweenness_centrality.go ├── betweenness_centrality_test.go ├── centrality_testdata_test.go ├── choice.go ├── choice_test.go ├── combinedattach.go ├── externalscoreattach.go ├── externalscoreattach_test.go ├── graph.go ├── graph_test.go ├── interface.go ├── log.go ├── manager.go ├── prefattach.go ├── prefattach_test.go ├── setup_test.go ├── simple_graph.go ├── simple_graph_test.go ├── top_centrality.go └── top_centrality_test.go ├── batch ├── batch.go ├── batch_test.go ├── interface.go ├── kvdb.go └── scheduler.go ├── blockcache ├── blockcache.go └── blockcache_test.go ├── brontide ├── README.md ├── bench_test.go ├── conn.go ├── fuzz_test.go ├── listener.go ├── noise.go └── noise_test.go ├── buffer ├── buffer_test.go ├── read.go ├── utils.go └── write.go ├── build ├── config.go ├── config_dev.go ├── config_prod.go ├── dependencies.go ├── deployment.go ├── deployment_dev.go ├── deployment_prod.go ├── handler_sets.go ├── handlers.go ├── log.go ├── log_default.go ├── log_nolog.go ├── log_shutdown.go ├── log_stdlog.go ├── log_test.go ├── loglevel_critical.go ├── loglevel_debug.go ├── loglevel_default.go ├── loglevel_error.go ├── loglevel_info.go ├── loglevel_off.go ├── loglevel_trace.go ├── loglevel_warn.go ├── logrotator.go ├── sub_logger.go └── version.go ├── cert ├── go.mod ├── go.sum ├── selfsigned.go ├── selfsigned_test.go └── tls.go ├── chainio ├── README.md ├── blockbeat.go ├── blockbeat_test.go ├── consumer.go ├── consumer_test.go ├── dispatcher.go ├── dispatcher_test.go ├── interface.go ├── log.go └── mocks.go ├── chainntnfs ├── README.md ├── best_block_view.go ├── best_block_view_test.go ├── bitcoindnotify │ ├── bitcoind.go │ ├── bitcoind_dev.go │ ├── bitcoind_test.go │ └── driver.go ├── btcdnotify │ ├── btcd.go │ ├── btcd_dev.go │ ├── btcd_test.go │ └── driver.go ├── errors.go ├── interface.go ├── interface_dev.go ├── log.go ├── mempool.go ├── mempool_test.go ├── mocks.go ├── neutrinonotify │ ├── driver.go │ ├── neutrino.go │ └── neutrino_dev.go ├── test │ ├── bitcoind │ │ └── bitcoind_test.go │ ├── btcd │ │ └── btcd_test.go │ ├── neutrino │ │ └── neutrino_test.go │ └── test_interface.go ├── test_utils.go ├── txnotifier.go └── txnotifier_test.go ├── chainreg ├── chainparams.go ├── chainregistry.go ├── log.go ├── no_chain_backend.go └── taproot_check.go ├── chanacceptor ├── acceptor_test.go ├── chainedacceptor.go ├── errors.go ├── interface.go ├── log.go ├── merge.go ├── merge_test.go ├── rpcacceptor.go ├── rpcacceptor_test.go ├── zeroconfacceptor.go └── zeroconfacceptor_test.go ├── chanbackup ├── backup.go ├── backup_test.go ├── backupfile.go ├── backupfile_test.go ├── log.go ├── multi.go ├── multi_test.go ├── pubsub.go ├── pubsub_test.go ├── recover.go ├── recover_test.go ├── single.go └── single_test.go ├── chanfitness ├── chanevent.go ├── chanevent_test.go ├── chaneventstore.go ├── chaneventstore_test.go ├── chaneventstore_testctx_test.go ├── interface.go ├── log.go ├── rate_limit.go └── rate_limit_test.go ├── channel_notifier.go ├── channeldb ├── README.md ├── addr_source.go ├── addr_source_test.go ├── channel.go ├── channel_test.go ├── codec.go ├── db.go ├── db_test.go ├── duplicate_payments.go ├── error.go ├── forwarding_log.go ├── forwarding_log_test.go ├── forwarding_package.go ├── forwarding_package_test.go ├── forwarding_policy.go ├── height_hint.go ├── height_hint_test.go ├── invoice_test.go ├── invoices.go ├── legacy_serialization.go ├── log.go ├── meta.go ├── meta_test.go ├── migration │ ├── create_tlb.go │ ├── create_tlb_test.go │ ├── lnwire21 │ │ ├── accept_channel.go │ │ ├── announcement_signatures.go │ │ ├── channel_announcement.go │ │ ├── channel_id.go │ │ ├── channel_reestablish.go │ │ ├── channel_update.go │ │ ├── closing_signed.go │ │ ├── commit_sig.go │ │ ├── custom_records.go │ │ ├── error.go │ │ ├── features.go │ │ ├── funding_created.go │ │ ├── funding_locked.go │ │ ├── funding_signed.go │ │ ├── gossip_timestamp_range.go │ │ ├── init_message.go │ │ ├── lnwire.go │ │ ├── message.go │ │ ├── msat.go │ │ ├── netaddress.go │ │ ├── node_announcement.go │ │ ├── onion_error.go │ │ ├── open_channel.go │ │ ├── ping.go │ │ ├── pong.go │ │ ├── query_channel_range.go │ │ ├── query_short_chan_ids.go │ │ ├── reply_channel_range.go │ │ ├── reply_short_chan_ids_end.go │ │ ├── revoke_and_ack.go │ │ ├── short_channel_id.go │ │ ├── shutdown.go │ │ ├── signature.go │ │ ├── true_boolean.go │ │ ├── update_add_htlc.go │ │ ├── update_fail_htlc.go │ │ ├── update_fail_malformed_htlc.go │ │ ├── update_fee.go │ │ └── update_fulfill_htlc.go │ └── log.go ├── migration12 │ ├── invoices.go │ ├── log.go │ ├── migration.go │ └── migration_test.go ├── migration13 │ ├── log.go │ ├── migration.go │ └── migration_test.go ├── migration16 │ ├── log.go │ ├── migration.go │ └── migration_test.go ├── migration20 │ ├── codec.go │ ├── log.go │ ├── migration.go │ └── migration_test.go ├── migration21 │ ├── common │ │ └── enclosed_types.go │ ├── current │ │ ├── current_codec.go │ │ └── current_encoding.go │ ├── legacy │ │ ├── legacy_codec.go │ │ └── legacy_decoding.go │ ├── migration.go │ └── migration_test.go ├── migration23 │ ├── migration.go │ └── migration_test.go ├── migration24 │ ├── log.go │ ├── migration.go │ └── migration_test.go ├── migration25 │ ├── channel.go │ ├── log.go │ ├── migration.go │ └── migration_test.go ├── migration26 │ ├── channel.go │ ├── log.go │ ├── migration.go │ └── migration_test.go ├── migration27 │ ├── channel.go │ ├── log.go │ ├── migration.go │ └── migration_test.go ├── migration29 │ ├── codec.go │ ├── log.go │ ├── migration.go │ └── migration_test.go ├── migration30 │ ├── iterator.go │ ├── iterator_test.go │ ├── lnwallet.go │ ├── log.go │ ├── migration.go │ ├── migration_test.go │ ├── revocation_log.go │ ├── test_mock.go │ └── test_utils.go ├── migration31 │ ├── log.go │ ├── migration.go │ ├── migration_test.go │ └── store.go ├── migration32 │ ├── codec.go │ ├── hop.go │ ├── log.go │ ├── migration.go │ ├── migration_test.go │ ├── mission_control_store.go │ └── route.go ├── migration33 │ ├── log.go │ ├── migration.go │ └── migration_test.go ├── migration_01_to_11 │ ├── addr.go │ ├── channel.go │ ├── channel_test.go │ ├── codec.go │ ├── db.go │ ├── error.go │ ├── graph.go │ ├── graph_test.go │ ├── invoices.go │ ├── legacy_serialization.go │ ├── log.go │ ├── meta.go │ ├── meta_test.go │ ├── migration_09_legacy_serialization.go │ ├── migration_10_route_tlv_records.go │ ├── migration_11_invoices.go │ ├── migration_11_invoices_test.go │ ├── migrations.go │ ├── migrations_test.go │ ├── options.go │ ├── payment_control.go │ ├── payments.go │ ├── payments_test.go │ ├── route.go │ └── zpay32 │ │ ├── amountunits.go │ │ ├── bech32.go │ │ ├── decode.go │ │ ├── hophint.go │ │ └── invoice.go ├── migtest │ ├── migtest.go │ └── raw_db.go ├── mp_payment.go ├── mp_payment_test.go ├── nodes.go ├── nodes_test.go ├── options.go ├── paginate.go ├── payment_control.go ├── payment_control_test.go ├── payment_status.go ├── payment_status_test.go ├── payments.go ├── payments_test.go ├── peers.go ├── peers_test.go ├── reports.go ├── reports_test.go ├── revocation_log.go ├── revocation_log_test.go ├── setup_test.go ├── waitingproof.go ├── waitingproof_test.go ├── witness_cache.go └── witness_cache_test.go ├── channelnotifier ├── channelnotifier.go └── log.go ├── chanrestore.go ├── clock ├── default_clock.go ├── go.mod ├── go.sum ├── interface.go ├── test_clock.go └── test_clock_test.go ├── cluster ├── etcd_elector.go ├── etcd_elector_factory.go ├── etcd_elector_test.go ├── factory.go ├── interface.go └── log.go ├── cmd ├── commands │ ├── arg_parse.go │ ├── arg_parse_test.go │ ├── autopilotrpc_active.go │ ├── autopilotrpc_default.go │ ├── chainrpc_active.go │ ├── chainrpc_default.go │ ├── cmd_custom.go │ ├── cmd_debug.go │ ├── cmd_import_mission_control.go │ ├── cmd_invoice.go │ ├── cmd_macaroon.go │ ├── cmd_mission_control.go │ ├── cmd_open_channel.go │ ├── cmd_payments.go │ ├── cmd_profile.go │ ├── cmd_state.go │ ├── cmd_update_chan_status.go │ ├── cmd_version.go │ ├── cmd_walletunlocker.go │ ├── commands.go │ ├── commands_test.go │ ├── devrpc_active.go │ ├── devrpc_default.go │ ├── invoicesrpc_active.go │ ├── invoicesrpc_default.go │ ├── macaroon_jar.go │ ├── macaroon_jar_test.go │ ├── main.go │ ├── neutrino_active.go │ ├── neutrino_default.go │ ├── peersrpc_active.go │ ├── peersrpc_default.go │ ├── profile.go │ ├── routerrpc.go │ ├── types.go │ ├── walletrpc_active.go │ ├── walletrpc_default.go │ ├── walletrpc_types.go │ ├── watchtower_active.go │ ├── watchtower_default.go │ └── wtclient.go ├── lncli │ └── main.go └── lnd │ └── main.go ├── config.go ├── config_builder.go ├── config_test.go ├── contractcourt ├── anchor_resolver.go ├── breach_arbitrator.go ├── breach_arbitrator_test.go ├── breach_resolver.go ├── briefcase.go ├── briefcase_test.go ├── chain_arbitrator.go ├── chain_arbitrator_test.go ├── chain_watcher.go ├── chain_watcher_test.go ├── channel_arbitrator.go ├── channel_arbitrator_test.go ├── commit_sweep_resolver.go ├── commit_sweep_resolver_test.go ├── config.go ├── config_test.go ├── contract_resolver.go ├── htlc_incoming_contest_resolver.go ├── htlc_incoming_contest_resolver_test.go ├── htlc_lease_resolver.go ├── htlc_outgoing_contest_resolver.go ├── htlc_outgoing_contest_resolver_test.go ├── htlc_success_resolver.go ├── htlc_success_resolver_test.go ├── htlc_timeout_resolver.go ├── htlc_timeout_resolver_test.go ├── interfaces.go ├── log.go ├── mock_htlcnotifier_test.go ├── mock_registry_test.go ├── nursery_store.go ├── nursery_store_test.go ├── setup_test.go ├── taproot_briefcase.go ├── taproot_briefcase_test.go ├── testdata │ └── rapid │ │ └── TestHtlcAuxBlobEncodeDecode │ │ └── TestHtlcAuxBlobEncodeDecode-20240902140253-81338.fail ├── utils_test.go ├── utxonursery.go └── utxonursery_test.go ├── contrib ├── init │ ├── README.md │ └── lnd.service └── lncli.bash-completion ├── dev.Dockerfile ├── discovery ├── ban.go ├── ban_test.go ├── bootstrapper.go ├── chan_series.go ├── gossiper.go ├── gossiper_test.go ├── log.go ├── message_store.go ├── message_store_test.go ├── mock_test.go ├── reliable_sender.go ├── reliable_sender_test.go ├── sync_manager.go ├── sync_manager_test.go ├── syncer.go ├── syncer_test.go ├── validation_barrier.go └── validation_barrier_test.go ├── doc.go ├── docker ├── README.md ├── bitcoind │ ├── Dockerfile │ └── start-bitcoind.sh ├── btcd │ ├── Dockerfile │ ├── start-btcctl.sh │ └── start-btcd.sh ├── docker-compose-bitcoind.yml ├── docker-compose.yml └── lnd │ └── start-lnd.sh ├── docs ├── DOCKER.md ├── INSTALL.md ├── MAKEFILE.md ├── alloy-models │ ├── README.md │ └── linear-fee-function │ │ ├── READM.md │ │ ├── counter-example-show.png │ │ ├── counter-example.png │ │ ├── fixed-model.png │ │ └── linear-fee.als ├── code_contribution_guidelines.md ├── configuring_tor.md ├── debugging_lnd.md ├── development_guidelines.md ├── etcd.md ├── fuzz.md ├── grpc │ ├── c#.md │ ├── java.md │ ├── javascript.md │ ├── python.md │ └── ruby.md ├── key_import.md ├── leader_election.md ├── macaroons.md ├── musig2.md ├── nat_traversal.md ├── postgres.md ├── psbt.md ├── recovery.md ├── release-notes │ ├── release-notes-0.13.1.md │ ├── release-notes-0.13.2.md │ ├── release-notes-0.13.3.md │ ├── release-notes-0.14.0.md │ ├── release-notes-0.14.1.md │ ├── release-notes-0.14.2.md │ ├── release-notes-0.14.3.md │ ├── release-notes-0.15.0.md │ ├── release-notes-0.15.1.md │ ├── release-notes-0.15.2.md │ ├── release-notes-0.15.3.md │ ├── release-notes-0.15.4.md │ ├── release-notes-0.15.5.md │ ├── release-notes-0.16.0.md │ ├── release-notes-0.16.1.md │ ├── release-notes-0.16.2.md │ ├── release-notes-0.16.3.md │ ├── release-notes-0.17.0.md │ ├── release-notes-0.17.1.md │ ├── release-notes-0.17.3.md │ ├── release-notes-0.17.4.md │ ├── release-notes-0.18.0.md │ ├── release-notes-0.18.1.md │ ├── release-notes-0.18.2.md │ ├── release-notes-0.18.3.md │ ├── release-notes-0.18.4.md │ ├── release-notes-0.18.5.md │ ├── release-notes-0.19.0.md │ ├── release-notes-0.19.1.md │ ├── release-notes-0.20.0.md │ └── release-notes-template.md ├── release.md ├── remote-signing.md ├── rest │ └── websockets.md ├── review.md ├── ruby-thing.rb ├── safety.md ├── signing_release_candidate.md ├── sqlite.md ├── wallet.md ├── watchtower.md └── zero_conf_channels.md ├── feature ├── default_sets.go ├── deps.go ├── deps_test.go ├── manager.go ├── manager_internal_test.go ├── required.go └── set.go ├── fn ├── conc_queue.go ├── context_guard.go ├── context_guard_test.go ├── either.go ├── either_test.go ├── events.go ├── fn.go ├── func.go ├── go.mod ├── go.sum ├── goroutine_manager.go ├── goroutine_manager_test.go ├── io.go ├── io_test.go ├── list.go ├── list_test.go ├── map.go ├── map_test.go ├── option.go ├── option_test.go ├── predicate.go ├── queue.go ├── recv.go ├── req.go ├── result.go ├── result_test.go ├── send.go ├── set.go ├── slice.go ├── slice_test.go ├── t2.go └── tests.go ├── funding ├── aux_funding.go ├── batch.go ├── batch_test.go ├── commitment_type_negotiation.go ├── commitment_type_negotiation_test.go ├── config_integration.go ├── interfaces.go ├── log.go ├── manager.go └── manager_test.go ├── go.mod ├── go.sum ├── graph ├── builder.go ├── builder_test.go ├── db │ ├── addr.go │ ├── addr_test.go │ ├── channel_cache.go │ ├── channel_cache_test.go │ ├── codec.go │ ├── errors.go │ ├── graph.go │ ├── graph_cache.go │ ├── graph_cache_test.go │ ├── graph_test.go │ ├── interfaces.go │ ├── kv_store.go │ ├── log.go │ ├── models │ │ ├── cached_edge_policy.go │ │ ├── channel.go │ │ ├── channel_auth_proof.go │ │ ├── channel_edge_info.go │ │ ├── channel_edge_policy.go │ │ ├── inbound_fee.go │ │ ├── inbound_fee_test.go │ │ └── node.go │ ├── notifications.go │ ├── options.go │ ├── reject_cache.go │ ├── reject_cache_test.go │ ├── setup_test.go │ ├── sql_store.go │ ├── test_kvdb.go │ ├── test_postgres.go │ └── test_sqlite.go ├── errors.go ├── interfaces.go ├── log.go ├── notifications_test.go ├── setup_test.go ├── stats.go └── testdata │ ├── basic_graph.json │ └── spec_example.json ├── healthcheck ├── diskcheck.go ├── diskcheck_js.go ├── diskcheck_netbsd.go ├── diskcheck_openbsd.go ├── diskcheck_solaris.go ├── diskcheck_windows.go ├── go.mod ├── go.sum ├── healthcheck.go ├── healthcheck_test.go ├── log.go └── tor_connection.go ├── htlcswitch ├── circuit.go ├── circuit_map.go ├── circuit_map_test.go ├── circuit_test.go ├── decayedlog.go ├── decayedlog_test.go ├── failure.go ├── failure_detail.go ├── failure_test.go ├── held_htlc_set.go ├── held_htlc_set_test.go ├── hodl │ ├── config_dev.go │ ├── config_prod.go │ ├── flags.go │ ├── mask_dev.go │ ├── mask_prod.go │ └── mask_test.go ├── hop │ ├── error_encryptor.go │ ├── forwarding_info.go │ ├── fuzz_test.go │ ├── iterator.go │ ├── iterator_test.go │ ├── log.go │ ├── payload.go │ ├── payload_test.go │ └── type.go ├── htlcnotifier.go ├── interceptable_switch.go ├── interfaces.go ├── link.go ├── link_isolated_test.go ├── link_test.go ├── linkfailure.go ├── log.go ├── mailbox.go ├── mailbox_test.go ├── mock.go ├── packet.go ├── payment_result.go ├── payment_result_test.go ├── quiescer.go ├── quiescer_test.go ├── resolution_store.go ├── resolution_store_test.go ├── sequencer.go ├── switch.go ├── switch_test.go ├── test_utils.go └── testdata │ └── long_failure_msg.json ├── input ├── fuzz_script_is_op_return_test.go ├── input.go ├── mocks.go ├── musig2.go ├── musig2_session_manager.go ├── musig2_test.go ├── script_desc.go ├── script_utils.go ├── script_utils_test.go ├── signdescriptor.go ├── signdescriptor_test.go ├── signer.go ├── size.go ├── size_test.go ├── taproot.go ├── taproot_test.go ├── test_utils.go ├── txout.go ├── txout_test.go └── witnessgen.go ├── intercepted_forward.go ├── internal └── musig2v040 │ ├── README.md │ ├── bench_test.go │ ├── context.go │ ├── keys.go │ ├── musig2_test.go │ ├── nonces.go │ └── sign.go ├── invoices ├── errors.go ├── interface.go ├── invoice_expiry_watcher.go ├── invoice_expiry_watcher_test.go ├── invoiceregistry.go ├── invoiceregistry_test.go ├── invoices.go ├── invoices_test.go ├── kv_sql_migration_test.go ├── log.go ├── mock.go ├── modification_interceptor.go ├── modification_interceptor_test.go ├── resolution.go ├── resolution_result.go ├── setup_test.go ├── sql_migration.go ├── sql_migration_test.go ├── sql_store.go ├── test_utils.go ├── test_utils_test.go ├── testdata │ └── channel.db ├── update.go ├── update_invoice.go └── update_invoice_test.go ├── itest ├── README.md ├── config.go ├── flakes.go ├── list_exclude_test.go ├── list_off_test.go ├── list_on_test.go ├── lnd_access_perm_test.go ├── lnd_amp_test.go ├── lnd_bump_fee.go ├── lnd_channel_backup_test.go ├── lnd_channel_balance_test.go ├── lnd_channel_force_close_test.go ├── lnd_channel_funding_fund_max_test.go ├── lnd_channel_funding_utxo_selection_test.go ├── lnd_channel_graph_test.go ├── lnd_channel_policy_test.go ├── lnd_coop_close_external_delivery_test.go ├── lnd_coop_close_rbf_test.go ├── lnd_coop_close_with_htlcs_test.go ├── lnd_custom_features.go ├── lnd_custom_message_test.go ├── lnd_estimate_route_fee_test.go ├── lnd_etcd_failover_test.go ├── lnd_experimental_endorsement.go ├── lnd_forward_interceptor_test.go ├── lnd_funding_test.go ├── lnd_hold_invoice_force_test.go ├── lnd_hold_persistence_test.go ├── lnd_htlc_test.go ├── lnd_htlc_timeout_resolver_test.go ├── lnd_invoice_acceptor_test.go ├── lnd_invoice_migration_test.go ├── lnd_macaroons_test.go ├── lnd_max_channel_size_test.go ├── lnd_max_htlcs_test.go ├── lnd_misc_test.go ├── lnd_mpp_test.go ├── lnd_multi-hop-error-propagation_test.go ├── lnd_multi-hop-payments_test.go ├── lnd_multi-hop_force_close_test.go ├── lnd_network_test.go ├── lnd_neutrino_test.go ├── lnd_no_etcd_dummy_failover_test.go ├── lnd_nonstd_sweep_test.go ├── lnd_onchain_test.go ├── lnd_open_channel_test.go ├── lnd_payment_test.go ├── lnd_psbt_test.go ├── lnd_quiescence_test.go ├── lnd_recovery_test.go ├── lnd_remote_signer_test.go ├── lnd_res_handoff_test.go ├── lnd_rest_api_test.go ├── lnd_revocation_test.go ├── lnd_route_blinding_test.go ├── lnd_routing_test.go ├── lnd_rpc_middleware_interceptor_test.go ├── lnd_signer_test.go ├── lnd_single_hop_invoice_test.go ├── lnd_sweep_test.go ├── lnd_switch_test.go ├── lnd_taproot_test.go ├── lnd_test.go ├── lnd_trackpayments_test.go ├── lnd_wallet.go ├── lnd_wallet_import_test.go ├── lnd_watchtower_test.go ├── lnd_wipe_fwdpkgs_test.go ├── lnd_wumbo_channels_test.go ├── lnd_zero_conf_test.go ├── log_check_errors.sh └── log_substitutions.txt ├── keychain ├── bench_test.go ├── btcwallet.go ├── derivation.go ├── ecdh.go ├── interface_test.go └── signer.go ├── kvdb ├── backend.go ├── backend_js.go ├── bolt_compact.go ├── bolt_fixture.go ├── bolt_test.go ├── config.go ├── debug.go ├── etcd │ ├── bucket.go │ ├── bucket_test.go │ ├── commit_queue.go │ ├── commit_queue_test.go │ ├── config.go │ ├── db.go │ ├── db_test.go │ ├── debug.go │ ├── driver.go │ ├── driver_test.go │ ├── embed.go │ ├── fixture.go │ ├── nodebug.go │ ├── readwrite_bucket.go │ ├── readwrite_cursor.go │ ├── readwrite_tx.go │ ├── readwrite_tx_test.go │ ├── stm.go │ ├── stm_test.go │ └── walletdb_interface_test.go ├── etcd_test.go ├── go.mod ├── go.sum ├── interface.go ├── kvdb_etcd.go ├── kvdb_no_etcd.go ├── kvdb_no_postgres.go ├── kvdb_no_sqlite.go ├── kvdb_postgres.go ├── kvdb_sqlite.go ├── log.go ├── nodebug.go ├── postgres │ ├── config.go │ ├── db.go │ ├── db_test.go │ ├── driver.go │ ├── fixture.go │ └── fixture_interface.go ├── postgres_test.go ├── prefetch_test.go ├── readwrite_bucket_test.go ├── readwrite_cursor_test.go ├── readwrite_tx_test.go ├── sqlbase │ ├── db.go │ ├── db_conn_set.go │ ├── log.go │ ├── no_sql.go │ ├── readwrite_bucket.go │ ├── readwrite_cursor.go │ ├── readwrite_tx.go │ └── schema.go ├── sqlite │ ├── config.go │ ├── db.go │ ├── db_test.go │ └── driver.go ├── test.go └── test_utils.go ├── labels └── labels.go ├── lncfg ├── address.go ├── address_test.go ├── autopilot.go ├── bitcoind.go ├── btcd.go ├── caches.go ├── chain.go ├── cluster.go ├── color.go ├── color_test.go ├── config.go ├── db.go ├── db_test.go ├── dev.go ├── dev_integration.go ├── error.go ├── fee.go ├── gossip.go ├── healthcheck.go ├── htlcswitch.go ├── interface.go ├── invoices.go ├── log.go ├── monitoring_off.go ├── monitoring_on.go ├── neutrino.go ├── pprof.go ├── protocol.go ├── protocol_experimental_off.go ├── protocol_experimental_on.go ├── protocol_integration.go ├── protocol_legacy_off.go ├── protocol_legacy_on.go ├── remotesigner.go ├── routing.go ├── rpcmiddleware.go ├── sweeper.go ├── tor.go ├── watchtower.go ├── workers.go ├── workers_test.go └── wtclient.go ├── lnd.go ├── lnencrypt ├── crypto.go ├── crypto_test.go └── test_utils.go ├── lnmock ├── chain.go ├── clock.go └── routing.go ├── lnpeer ├── errors.go ├── mock_peer.go └── peer.go ├── lnrpc ├── .clang-format ├── Dockerfile ├── README.md ├── autopilotrpc │ ├── autopilot.pb.go │ ├── autopilot.pb.gw.go │ ├── autopilot.pb.json.go │ ├── autopilot.proto │ ├── autopilot.swagger.json │ ├── autopilot.yaml │ ├── autopilot_grpc.pb.go │ ├── autopilot_server.go │ ├── config_active.go │ ├── config_default.go │ ├── driver.go │ └── log.go ├── chainrpc │ ├── chain_server.go │ ├── chainkit.pb.go │ ├── chainkit.pb.gw.go │ ├── chainkit.pb.json.go │ ├── chainkit.proto │ ├── chainkit.swagger.json │ ├── chainkit.yaml │ ├── chainkit_grpc.pb.go │ ├── chainnotifier.pb.go │ ├── chainnotifier.pb.gw.go │ ├── chainnotifier.pb.json.go │ ├── chainnotifier.proto │ ├── chainnotifier.swagger.json │ ├── chainnotifier.yaml │ ├── chainnotifier_grpc.pb.go │ ├── config_active.go │ ├── config_default.go │ ├── driver.go │ └── log.go ├── devrpc │ ├── config_active.go │ ├── config_default.go │ ├── dev.pb.go │ ├── dev.pb.gw.go │ ├── dev.pb.json.go │ ├── dev.proto │ ├── dev.swagger.json │ ├── dev.yaml │ ├── dev_grpc.pb.go │ ├── dev_server.go │ ├── driver.go │ └── log.go ├── file_utils.go ├── gen_protos.sh ├── gen_protos_docker.sh ├── invoicesrpc │ ├── addinvoice.go │ ├── addinvoice_test.go │ ├── config_active.go │ ├── config_default.go │ ├── driver.go │ ├── htlc_modifier.go │ ├── interfaces.go │ ├── invoices.pb.go │ ├── invoices.pb.gw.go │ ├── invoices.pb.json.go │ ├── invoices.proto │ ├── invoices.swagger.json │ ├── invoices.yaml │ ├── invoices_grpc.pb.go │ ├── invoices_server.go │ ├── log.go │ └── utils.go ├── lightning.pb.go ├── lightning.pb.gw.go ├── lightning.pb.json.go ├── lightning.proto ├── lightning.swagger.json ├── lightning.yaml ├── lightning_grpc.pb.go ├── lnclipb │ ├── lncli.pb.go │ ├── lncli.proto │ ├── lncli.swagger.json │ └── lncli.yaml ├── marshall_utils.go ├── metadata.go ├── neutrinorpc │ ├── config_active.go │ ├── config_default.go │ ├── driver.go │ ├── log.go │ ├── neutrino.pb.go │ ├── neutrino.pb.gw.go │ ├── neutrino.proto │ ├── neutrino.swagger.json │ ├── neutrino.yaml │ ├── neutrino_grpc.pb.go │ ├── neutrino_server.go │ └── neutrinokit.pb.json.go ├── peersrpc │ ├── config_active.go │ ├── config_default.go │ ├── driver.go │ ├── log.go │ ├── peers.pb.go │ ├── peers.pb.gw.go │ ├── peers.pb.json.go │ ├── peers.proto │ ├── peers.swagger.json │ ├── peers.yaml │ ├── peers_grpc.pb.go │ └── peers_server.go ├── routerrpc │ ├── config.go │ ├── driver.go │ ├── forward_interceptor.go │ ├── log.go │ ├── router.pb.go │ ├── router.pb.gw.go │ ├── router.pb.json.go │ ├── router.proto │ ├── router.swagger.json │ ├── router.yaml │ ├── router_backend.go │ ├── router_backend_test.go │ ├── router_grpc.pb.go │ ├── router_server.go │ ├── router_server_deprecated.go │ ├── router_server_test.go │ ├── routing_config.go │ └── subscribe_events.go ├── rpc_utils.go ├── signrpc │ ├── config_active.go │ ├── config_default.go │ ├── driver.go │ ├── log.go │ ├── signer.pb.go │ ├── signer.pb.gw.go │ ├── signer.pb.json.go │ ├── signer.proto │ ├── signer.swagger.json │ ├── signer.yaml │ ├── signer_grpc.pb.go │ ├── signer_server.go │ └── signer_utils.go ├── state.pb.json.go ├── stateservice.pb.go ├── stateservice.pb.gw.go ├── stateservice.proto ├── stateservice.swagger.json ├── stateservice.yaml ├── stateservice_grpc.pb.go ├── sub_server.go ├── verrpc │ ├── driver.go │ ├── log.go │ ├── server.go │ ├── verrpc.pb.go │ ├── verrpc.pb.gw.go │ ├── verrpc.proto │ ├── verrpc.swagger.json │ ├── verrpc.yaml │ ├── verrpc_grpc.pb.go │ └── versioner.pb.json.go ├── walletrpc │ ├── config_active.go │ ├── config_default.go │ ├── driver.go │ ├── errors.go │ ├── log.go │ ├── psbt.go │ ├── walletkit.pb.go │ ├── walletkit.pb.gw.go │ ├── walletkit.pb.json.go │ ├── walletkit.proto │ ├── walletkit.swagger.json │ ├── walletkit.yaml │ ├── walletkit_grpc.pb.go │ ├── walletkit_server.go │ ├── walletkit_server_test.go │ ├── walletkit_util.go │ └── walletkit_util_test.go ├── walletunlocker.pb.go ├── walletunlocker.pb.gw.go ├── walletunlocker.pb.json.go ├── walletunlocker.proto ├── walletunlocker.swagger.json ├── walletunlocker.yaml ├── walletunlocker_grpc.pb.go ├── watchtowerrpc │ ├── config_active.go │ ├── config_default.go │ ├── driver.go │ ├── handler.go │ ├── interface.go │ ├── log.go │ ├── watchtower.pb.go │ ├── watchtower.pb.gw.go │ ├── watchtower.pb.json.go │ ├── watchtower.proto │ ├── watchtower.swagger.json │ ├── watchtower.yaml │ └── watchtower_grpc.pb.go ├── websocket_proxy.go └── wtclientrpc │ ├── config.go │ ├── driver.go │ ├── watchtowerclient.pb.json.go │ ├── wtclient.go │ ├── wtclient.pb.go │ ├── wtclient.pb.gw.go │ ├── wtclient.proto │ ├── wtclient.swagger.json │ ├── wtclient.yaml │ └── wtclient_grpc.pb.go ├── lntest ├── README.md ├── bitcoind.go ├── bitcoind_common.go ├── bitcoind_notxindex.go ├── bitcoind_rpcpolling.go ├── btcd.go ├── channels │ └── channels.go ├── doc.go ├── fee_service.go ├── harness.go ├── harness_assertion.go ├── harness_miner.go ├── harness_node_manager.go ├── harness_setup.go ├── miner │ └── miner.go ├── mock │ ├── chainio.go │ ├── chainnotifier.go │ ├── secretkeyring.go │ ├── signer.go │ ├── spendnotifier.go │ └── walletcontroller.go ├── neutrino.go ├── node │ ├── config.go │ ├── harness_node.go │ ├── state.go │ └── watcher.go ├── port │ └── port.go ├── rpc │ ├── chain_kit.go │ ├── chain_notifier.go │ ├── harness_rpc.go │ ├── invoices.go │ ├── lnd.go │ ├── neutrino_kit.go │ ├── peers.go │ ├── router.go │ ├── signer.go │ ├── state.go │ ├── wallet_kit.go │ ├── wallet_unlocker.go │ └── watchtower.go ├── unittest │ └── backend.go ├── utils.go └── wait │ ├── timeouts.go │ ├── timeouts_darwin.go │ ├── timeouts_remote_db.go │ ├── timeouts_windows.go │ └── wait.go ├── lntypes ├── channel_party.go ├── hash.go ├── preimage.go ├── txsize.go └── txsize_test.go ├── lnutils ├── README.md ├── chan.go ├── errors.go ├── fs.go ├── fs_test.go ├── log.go ├── memory.go ├── stream.go ├── sync_map.go ├── sync_map_bench_test.go └── sync_map_test.go ├── lnwallet ├── README.md ├── aux_leaf_store.go ├── aux_resolutions.go ├── aux_signer.go ├── btcwallet │ ├── blockchain.go │ ├── btcwallet.go │ ├── btcwallet_integration.go │ ├── btcwallet_test.go │ ├── config.go │ ├── driver.go │ ├── log.go │ ├── psbt.go │ ├── psbt_test.go │ ├── signer.go │ └── signer_test.go ├── chainfee │ ├── estimator.go │ ├── estimator_test.go │ ├── filtermanager.go │ ├── filtermanager_test.go │ ├── log.go │ ├── minfeemanager.go │ ├── minfeemanager_test.go │ ├── mocks.go │ ├── rates.go │ └── rates_test.go ├── chancloser │ ├── aux_closer.go │ ├── chancloser.go │ ├── chancloser_test.go │ ├── interface.go │ ├── log.go │ ├── mock.go │ ├── rbf_close.md │ ├── rbf_coop_msg_mapper.go │ ├── rbf_coop_states.go │ ├── rbf_coop_test.go │ └── rbf_coop_transitions.go ├── chanfunding │ ├── canned_assembler.go │ ├── coin_select.go │ ├── coin_select_test.go │ ├── interface.go │ ├── log.go │ ├── psbt_assembler.go │ ├── psbt_assembler_test.go │ └── wallet_assembler.go ├── channel.go ├── channel_test.go ├── chanvalidate │ ├── validate.go │ └── validate_test.go ├── close_test.go ├── commit_sort.go ├── commit_sort_test.go ├── commitment.go ├── commitment_chain.go ├── config.go ├── errors.go ├── interface.go ├── log.go ├── mock.go ├── musig_session.go ├── musig_session_test.go ├── parameters.go ├── parameters_test.go ├── payment_descriptor.go ├── rebroadcaster.go ├── rebroadcaster_test.go ├── reservation.go ├── revocation_producer.go ├── revocation_producer_itest.go ├── rpcwallet │ ├── healthcheck.go │ ├── log.go │ └── rpcwallet.go ├── sigpool.go ├── test │ ├── bitcoind │ │ └── bitcoind_test.go │ ├── btcd │ │ └── btcd_test.go │ ├── neutrino │ │ └── neutrino_test.go │ └── test_interface.go ├── test_utils.go ├── test_vectors_anchors.json ├── test_vectors_legacy.json ├── test_vectors_zero_fee_htlc_tx.json ├── transactions.go ├── transactions_test.go ├── update_log.go ├── wallet.go └── wallet_test.go ├── lnwire ├── README.md ├── accept_channel.go ├── accept_channel_test.go ├── announcement_signatures.go ├── announcement_signatures_2.go ├── channel_announcement.go ├── channel_announcement_2.go ├── channel_id.go ├── channel_id_test.go ├── channel_ready.go ├── channel_reestablish.go ├── channel_type.go ├── channel_type_test.go ├── channel_update.go ├── channel_update_2.go ├── closing_complete.go ├── closing_sig.go ├── closing_signed.go ├── commit_sig.go ├── commit_sig_test.go ├── custom.go ├── custom_records.go ├── custom_records_test.go ├── dyn_ack.go ├── dyn_propose.go ├── dyn_reject.go ├── encoding.go ├── error.go ├── extra_bytes.go ├── extra_bytes_test.go ├── features.go ├── features_test.go ├── funding_created.go ├── funding_signed.go ├── fuzz_test.go ├── gossip_timestamp_range.go ├── init_message.go ├── interfaces.go ├── kickoff_sig.go ├── lnwire.go ├── lnwire_test.go ├── message.go ├── message_test.go ├── msat.go ├── msat_test.go ├── musig2.go ├── netaddress.go ├── netaddress_test.go ├── node_announcement.go ├── node_announcement_test.go ├── onion_error.go ├── onion_error_test.go ├── opaque_addrs.go ├── open_channel.go ├── partial_sig.go ├── ping.go ├── pong.go ├── query_channel_range.go ├── query_channel_range_test.go ├── query_options.go ├── query_short_chan_ids.go ├── query_short_chan_ids_test.go ├── reply_channel_range.go ├── reply_channel_range_test.go ├── reply_short_chan_ids_end.go ├── revoke_and_ack.go ├── serialized_size_test.go ├── short_channel_id.go ├── short_channel_id_test.go ├── shutdown.go ├── shutdown_test.go ├── signature.go ├── signature_test.go ├── stfu.go ├── test_message.go ├── test_utils.go ├── timestamps.go ├── typed_delivery_addr.go ├── typed_delivery_addr_test.go ├── typed_fee.go ├── typed_fee_test.go ├── typed_lease_expiry.go ├── typed_lease_expiry_test.go ├── update_add_htlc.go ├── update_add_htlc_test.go ├── update_fail_htlc.go ├── update_fail_malformed_htlc.go ├── update_fee.go ├── update_fulfill_htlc.go ├── update_fulfill_htlc_test.go ├── warning.go ├── writer.go └── writer_test.go ├── log.go ├── logo.png ├── macaroons ├── README.md ├── auth.go ├── bake.go ├── bake_test.go ├── constraints.go ├── constraints_test.go ├── context.go ├── fuzz_test.go ├── security.go ├── security_integration.go ├── security_test.go ├── service.go ├── service_test.go ├── store.go └── store_test.go ├── make ├── builder.Dockerfile ├── fuzz_flags.mk ├── release_flags.mk └── testing_flags.mk ├── mobile ├── README.md ├── bindings.go ├── docs │ ├── proto_folder.png │ └── separate_gradle_module.png ├── gen_bindings.sh └── sample_lnd.conf ├── monitoring ├── log.go ├── monitoring_off.go └── monitoring_on.go ├── msgmux ├── log.go ├── msg_router.go └── msg_router_test.go ├── multimutex ├── multimutex.go └── multimutex_test.go ├── nat ├── pmp.go ├── traversal.go └── upnp.go ├── netann ├── chan_status_manager.go ├── chan_status_manager_test.go ├── channel_announcement.go ├── channel_announcement_test.go ├── channel_state.go ├── channel_update.go ├── channel_update_test.go ├── host_ann.go ├── host_ann_test.go ├── interface.go ├── log.go ├── msg_hash.go ├── node_announcement.go ├── node_signer.go └── sign.go ├── peer ├── brontide.go ├── brontide_test.go ├── chan_observer.go ├── daemon_adapters.go ├── interfaces.go ├── log.go ├── musig_chan_closer.go ├── ping_manager.go ├── ping_manager_test.go ├── setup_test.go └── test_utils.go ├── peernotifier ├── log.go └── peernotifier.go ├── pilot.go ├── pool ├── read.go ├── read_buffer.go ├── recycle.go ├── recycle_test.go ├── worker.go ├── worker_test.go ├── write.go └── write_buffer.go ├── protofsm ├── daemon_events.go ├── log.go ├── msg_mapper.go ├── state_machine.go └── state_machine_test.go ├── queue ├── circular_buf.go ├── circular_buf_test.go ├── gc_queue.go ├── gc_queue_test.go ├── go.mod ├── go.sum ├── priority_queue.go ├── priority_queue_test.go ├── queue.go └── queue_test.go ├── record ├── amp.go ├── blinded_data.go ├── blinded_data_test.go ├── custom_records.go ├── custom_records_test.go ├── experimental.go ├── hop.go ├── mpp.go └── record_test.go ├── routing ├── README.md ├── additional_edge.go ├── additional_edge_test.go ├── bandwidth.go ├── bandwidth_test.go ├── blindedpath │ ├── blinded_path.go │ ├── blinded_path_test.go │ └── log.go ├── blinding.go ├── blinding_test.go ├── chainview │ ├── bitcoind.go │ ├── btcd.go │ ├── interface.go │ ├── interface_test.go │ ├── log.go │ ├── neutrino.go │ └── queue.go ├── control_tower.go ├── control_tower_test.go ├── graph.go ├── heap.go ├── heap_test.go ├── integrated_routing_context_test.go ├── integrated_routing_test.go ├── localchans │ ├── log.go │ ├── manager.go │ └── manager_test.go ├── log.go ├── missioncontrol.go ├── missioncontrol_state.go ├── missioncontrol_state_test.go ├── missioncontrol_store.go ├── missioncontrol_store_test.go ├── missioncontrol_test.go ├── mock_graph_test.go ├── mock_test.go ├── nodepair.go ├── pathfind.go ├── pathfind_test.go ├── payment_lifecycle.go ├── payment_lifecycle_test.go ├── payment_session.go ├── payment_session_source.go ├── payment_session_test.go ├── probability_apriori.go ├── probability_apriori_test.go ├── probability_bimodal.go ├── probability_bimodal_test.go ├── probability_estimator.go ├── probability_estimator_test.go ├── result_interpretation.go ├── result_interpretation_test.go ├── route │ ├── route.go │ └── route_test.go ├── router.go ├── router_test.go ├── setup_test.go ├── shards │ ├── shard_tracker.go │ └── shard_tracker_test.go ├── testdata │ ├── basic_graph.json │ └── spec_example.json ├── unified_edges.go └── unified_edges_test.go ├── rpcperms ├── interceptor.go ├── log.go ├── middleware_handler.go └── middleware_handler_test.go ├── rpcserver.go ├── rpcserver_test.go ├── sample-lnd.conf ├── scripts ├── bw-compatibility-test │ ├── .env │ ├── README.md │ ├── compose.sh │ ├── docker-compose.override.yaml │ ├── docker-compose.yaml │ ├── execute.sh │ ├── network.sh │ └── test.sh ├── check-commit.sh ├── check-each-commit.sh ├── check-go-version-dockerfile.sh ├── check-go-version-yaml.sh ├── check-release-notes.sh ├── check-rest-annotations.sh ├── check-sample-lnd-conf.sh ├── fuzz.sh ├── gen_man_pages.sh ├── gen_sqlc_docker.sh ├── install_bitcoind.sh ├── itest_parallel.sh ├── itest_part.sh ├── keys │ ├── Crypt-iQ.asc │ ├── README.md │ ├── ViktorTigerstrom.asc │ ├── arshbot.asc │ ├── bhandras.asc │ ├── carlaKC.asc │ ├── ellemouton.asc │ ├── ffranr.asc │ ├── guggero.asc │ ├── hieblmi.asc │ ├── positiveblue.asc │ ├── proofofkeags.asc │ ├── roasbeef.asc │ ├── sputn1ck.asc │ ├── suheb.asc │ ├── wpaulino.asc │ ├── yyforyongyu.asc │ └── ziggie1984.asc ├── release.sh ├── tidy_modules.sh ├── unit-test-flake-hunter.sh ├── unit_test_modules.sh └── verify-install.sh ├── server.go ├── server_test.go ├── shachain ├── element.go ├── element_test.go ├── producer.go ├── producer_test.go ├── store.go ├── store_test.go └── utils.go ├── signal ├── log.go └── signal.go ├── sqlc.yaml ├── sqldb ├── config.go ├── go.mod ├── go.sum ├── interfaces.go ├── log.go ├── migrations.go ├── migrations_dev.go ├── migrations_prod.go ├── migrations_test.go ├── no_sqlite.go ├── postgres.go ├── postgres_fixture.go ├── postgres_test.go ├── schemas.go ├── sqlc │ ├── amp_invoices.sql.go │ ├── db.go │ ├── graph.sql.go │ ├── invoice_events.sql.go │ ├── invoices.sql.go │ ├── migration.sql.go │ ├── migrations │ │ ├── 000001_invoices.down.sql │ │ ├── 000001_invoices.up.sql │ │ ├── 000002_amp_invoices.down.sql │ │ ├── 000002_amp_invoices.up.sql │ │ ├── 000003_invoice_events.down.sql │ │ ├── 000003_invoice_events.up.sql │ │ ├── 000004_invoice_expiry_fix.down.sql │ │ ├── 000004_invoice_expiry_fix.up.sql │ │ ├── 000005_migration_tracker.down.sql │ │ ├── 000005_migration_tracker.up.sql │ │ ├── 000006_invoice_migration.down.sql │ │ ├── 000006_invoice_migration.up.sql │ │ ├── 000007_graph.down.sql │ │ └── 000007_graph.up.sql │ ├── models.go │ ├── querier.go │ └── queries │ │ ├── amp_invoices.sql │ │ ├── graph.sql │ │ ├── invoice_events.sql │ │ ├── invoices.sql │ │ └── migration.sql ├── sqlerrors.go ├── sqlerrors_no_sqlite.go ├── sqlite.go ├── sqlite_test.go └── sqlutils.go ├── subrpcserver_config.go ├── subscribe ├── interface.go ├── subscribe.go └── subscribe_test.go ├── sweep ├── README.md ├── aggregator.go ├── aggregator_test.go ├── defaults.go ├── fee_bumper.go ├── fee_bumper_test.go ├── fee_function.go ├── fee_function_test.go ├── interface.go ├── log.go ├── mock_test.go ├── setup_test.go ├── store.go ├── store_test.go ├── sweeper.go ├── sweeper_test.go ├── test_utils.go ├── tx_input_set.go ├── tx_input_set_test.go ├── txgenerator.go ├── txgenerator_test.go ├── walletsweep.go ├── walletsweep_test.go ├── weight_estimator.go └── weight_estimator_test.go ├── sweeper_wallet.go ├── ticker ├── force.go ├── go.mod ├── ticker.go └── ticker_test.go ├── tls_manager.go ├── tls_manager_test.go ├── tlv ├── fuzz_test.go ├── go.mod ├── go.sum ├── internal │ └── gen │ │ └── gen_tlv_types.go ├── primitive.go ├── primitive_test.go ├── record.go ├── record_test.go ├── record_type.go ├── record_type_test.go ├── stream.go ├── stream_test.go ├── tlv_test.go ├── tlv_type_param.go ├── tlv_types_generated.go ├── truncated.go ├── truncated_test.go ├── varint.go └── varint_test.go ├── tools ├── .custom-gcl.yml ├── Dockerfile ├── go.mod ├── go.sum ├── linters │ ├── go.mod │ ├── go.sum │ ├── ll.go │ └── ll_test.go └── tools.go ├── tor ├── README.md ├── cmd_info.go ├── cmd_info_test.go ├── cmd_onion.go ├── cmd_onion_test.go ├── controller.go ├── controller_test.go ├── go.mod ├── go.sum ├── log.go ├── net.go ├── onionaddr.go ├── tor.go └── tor_test.go ├── walletunlocker ├── service.go └── service_test.go ├── watchtower ├── blob │ ├── commitments.go │ ├── derivation.go │ ├── justice_kit.go │ ├── justice_kit_packet.go │ ├── justice_kit_test.go │ ├── type.go │ └── type_test.go ├── conf.go ├── config.go ├── errors.go ├── interface.go ├── log.go ├── lookout │ ├── interface.go │ ├── justice_descriptor.go │ ├── justice_descriptor_test.go │ ├── log.go │ ├── lookout.go │ ├── lookout_test.go │ ├── mock.go │ └── punisher.go ├── standalone.go ├── tlv_bench_test.go ├── wtclient │ ├── addr_iterator.go │ ├── addr_iterator_test.go │ ├── backup_task.go │ ├── backup_task_internal_test.go │ ├── candidate_iterator.go │ ├── candidate_iterator_test.go │ ├── client.go │ ├── client_test.go │ ├── errors.go │ ├── fuzz_test.go │ ├── interface.go │ ├── log.go │ ├── manager.go │ ├── queue.go │ ├── queue_test.go │ ├── sess_close_min_heap.go │ ├── sess_close_min_heap_test.go │ ├── session_negotiator.go │ ├── session_queue.go │ └── stats.go ├── wtdb │ ├── client_chan_summary.go │ ├── client_db.go │ ├── client_db_test.go │ ├── client_session.go │ ├── codec.go │ ├── codec_test.go │ ├── db_common.go │ ├── log.go │ ├── migration1 │ │ ├── client_db.go │ │ ├── client_db_test.go │ │ ├── codec.go │ │ └── log.go │ ├── migration2 │ │ ├── client_db.go │ │ ├── client_db_test.go │ │ ├── codec.go │ │ └── log.go │ ├── migration3 │ │ ├── client_db.go │ │ ├── client_db_test.go │ │ ├── codec.go │ │ └── log.go │ ├── migration4 │ │ ├── client_db.go │ │ ├── client_db_test.go │ │ ├── codec.go │ │ ├── log.go │ │ └── range_index.go │ ├── migration5 │ │ ├── client_db.go │ │ ├── client_db_test.go │ │ ├── codec.go │ │ └── log.go │ ├── migration6 │ │ ├── client_db.go │ │ ├── client_db_test.go │ │ ├── codec.go │ │ └── log.go │ ├── migration7 │ │ ├── client_db.go │ │ ├── client_db_test.go │ │ ├── codec.go │ │ └── log.go │ ├── migration8 │ │ ├── codec.go │ │ ├── log.go │ │ ├── migration.go │ │ ├── migration_test.go │ │ └── range_index.go │ ├── queue.go │ ├── queue_test.go │ ├── range_index.go │ ├── range_index_test.go │ ├── session_id.go │ ├── session_info.go │ ├── session_state_update.go │ ├── tower.go │ ├── tower_db.go │ ├── tower_db_test.go │ └── version.go ├── wtmock │ ├── keyring.go │ ├── peer.go │ ├── queue.go │ ├── signer.go │ └── tower_db.go ├── wtpolicy │ ├── policy.go │ └── policy_test.go ├── wtserver │ ├── create_session.go │ ├── delete_session.go │ ├── interface.go │ ├── log.go │ ├── server.go │ ├── server_test.go │ └── state_update.go └── wtwire │ ├── create_session.go │ ├── create_session_reply.go │ ├── delete_session.go │ ├── delete_session_reply.go │ ├── error.go │ ├── error_code.go │ ├── features.go │ ├── fuzz_test.go │ ├── init.go │ ├── init_test.go │ ├── message.go │ ├── state_update.go │ ├── state_update_reply.go │ ├── summary.go │ ├── wtwire.go │ └── wtwire_test.go ├── witness_beacon.go ├── witness_beacon_test.go └── zpay32 ├── README.md ├── amountunits.go ├── bech32.go ├── blinded_path.go ├── decode.go ├── encode.go ├── fuzz_test.go ├── hophint.go ├── invoice.go ├── invoice_internal_test.go └── invoice_test.go /.custom-gcl.yml: -------------------------------------------------------------------------------- 1 | version: v1.57.0 2 | plugins: 3 | - module: 'github.com/lightningnetwork/lnd/tools/linters' 4 | path: ./tools/linters -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig is awesome: https://EditorConfig.org 2 | 3 | # Top-most EditorConfig file. 4 | root = true 5 | 6 | # Unix-style newlines with a newline ending every file. 7 | [*.md] 8 | end_of_line = lf 9 | insert_final_newline = true 10 | max_line_length = 80 11 | 12 | # 8 space indentation for Golang code. 13 | [*.go] 14 | indent_style = tab 15 | indent_size = 8 16 | max_line_length = 80 17 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a bug report. Please use the discussions section for general or troubleshooting questions. 4 | title: '[bug]: ' 5 | labels: ["bug", "needs triage"] 6 | assignees: '' 7 | --- 8 | 9 | ### Background 10 | 11 | Describe your issue here. 12 | 13 | ### Your environment 14 | 15 | * version of `lnd` 16 | * which operating system (`uname -a` on *Nix) 17 | * version of `btcd`, `bitcoind`, or other backend 18 | * any other relevant environment details 19 | 20 | ### Steps to reproduce 21 | 22 | Tell us how to reproduce this issue. Please provide stacktraces and links to code in question. 23 | 24 | ### Expected behaviour 25 | 26 | Tell us what should happen 27 | 28 | ### Actual behaviour 29 | 30 | Tell us what happens instead 31 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: false 2 | contact_links: 3 | - name: Discussions 4 | url: https://github.com/lightningnetwork/lnd/discussions 5 | about: For general or troubleshooting questions or if you're not sure what issue type to pick. 6 | - name: Documentation for lnd and lightning-terminal 7 | url: https://docs.lightning.engineering/ 8 | about: Please make sure the documentation cannot answer your question first. 9 | - name: Lightning Community Slack 10 | url: https://lightning.engineering/slack.html 11 | about: Please ask and answer questions here. 12 | - name: Security issue disclosure policy 13 | url: https://github.com/lightningnetwork/lnd#security 14 | about: Please refer to this document when reporting security related issues. 15 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest a new feature for `lnd`. 4 | title: '[feature]: ' 5 | labels: enhancement 6 | assignees: '' 7 | --- 8 | 9 | **Is your feature request related to a problem? Please describe.** 10 | 11 | 12 | **Describe the solution you'd like** 13 | 14 | 15 | **Describe alternatives you've considered** 16 | 17 | 18 | **Additional context** 19 | 20 | -------------------------------------------------------------------------------- /.github/actions/rebase/action.yml: -------------------------------------------------------------------------------- 1 | name: "Rebase on to the PR target base branch" 2 | description: "A reusable workflow that's used to rebase the PR code on to the target base branch." 3 | 4 | runs: 5 | using: "composite" 6 | 7 | steps: 8 | - name: fetch and rebase on ${{ github.base_ref }} 9 | shell: bash 10 | run: | 11 | git remote add upstream https://github.com/${{ github.repository }} 12 | git fetch upstream ${{ github.base_ref }}:refs/remotes/upstream/${{ github.base_ref }} 13 | export GIT_COMMITTER_EMAIL="lnd-ci@example.com" 14 | export GIT_COMMITTER_NAME="LND CI" 15 | git rebase upstream/${{ github.base_ref }} 16 | -------------------------------------------------------------------------------- /.github/workflows/stats.yml: -------------------------------------------------------------------------------- 1 | name: Pull Request Stats 2 | 3 | on: 4 | pull_request: 5 | types: [opened] 6 | 7 | jobs: 8 | stats: 9 | runs-on: ubuntu-latest 10 | permissions: 11 | contents: read 12 | pull-requests: write 13 | steps: 14 | - name: Run pull request stats 15 | uses: flowwer-dev/pull-request-stats@v2.11.0 16 | with: 17 | period: 30 # 30 days of review stats 18 | charts: true 19 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "editor.tabSize": 8, 3 | "editor.rulers": [ 4 | 80 5 | ], 6 | "go.buildTags": "autopilotrpc chainrpc dev invoicesrpc neutrinorpc peersrpc signrpc walletrpc watchtowerrpc" 7 | } -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | ## Supported Versions 4 | 5 | The last major lnd release is to be considered the current support version. Given an issue severe enough, a backport will be issued either to the prior major release or the set of releases considered utilized enough. 6 | 7 | ## Reporting a Vulnerability 8 | 9 | To report security issues, send an email to security@lightning.engineering (this list isn't to be used for support). 10 | 11 | The following key can be used to communicate sensitive information: `91FE 464C D751 01DA 6B6B  AB60 555C 6465 E5BC B3AF`. 12 | -------------------------------------------------------------------------------- /aezeed/cipherseed_integration.go: -------------------------------------------------------------------------------- 1 | //go:build integration 2 | 3 | package aezeed 4 | 5 | import "github.com/btcsuite/btcwallet/waddrmgr" 6 | 7 | func init() { 8 | // For the purposes of our itest, we'll crank down the scrypt params a 9 | // bit. 10 | scryptN = waddrmgr.FastScryptOptions.N 11 | scryptR = waddrmgr.FastScryptOptions.R 12 | scryptP = waddrmgr.FastScryptOptions.P 13 | } 14 | -------------------------------------------------------------------------------- /autopilot/log.go: -------------------------------------------------------------------------------- 1 | package autopilot 2 | 3 | import ( 4 | "github.com/btcsuite/btclog/v2" 5 | "github.com/lightningnetwork/lnd/build" 6 | ) 7 | 8 | // log is a logger that is initialized with no output filters. This 9 | // means the package will not perform any logging by default until the caller 10 | // requests it. 11 | var log btclog.Logger 12 | 13 | // The default amount of logging is none. 14 | func init() { 15 | UseLogger(build.NewSubLogger("ATPL", nil)) 16 | } 17 | 18 | // DisableLog disables all library log output. Logging output is disabled 19 | // by default until UseLogger is called. 20 | func DisableLog() { 21 | UseLogger(btclog.Disabled) 22 | } 23 | 24 | // UseLogger uses a specified Logger to output package logging info. 25 | // This should be used in preference to SetLogWriter if the caller is also 26 | // using btclog. 27 | func UseLogger(logger btclog.Logger) { 28 | log = logger 29 | } 30 | -------------------------------------------------------------------------------- /autopilot/setup_test.go: -------------------------------------------------------------------------------- 1 | package autopilot 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/lightningnetwork/lnd/kvdb" 7 | ) 8 | 9 | func TestMain(m *testing.M) { 10 | kvdb.RunTests(m) 11 | } 12 | -------------------------------------------------------------------------------- /buffer/read.go: -------------------------------------------------------------------------------- 1 | package buffer 2 | 3 | import ( 4 | "github.com/lightningnetwork/lnd/lnwire" 5 | ) 6 | 7 | // ReadSize represents the size of the maximum message that can be read off the 8 | // wire by brontide. The buffer is used to hold the ciphertext while the 9 | // brontide state machine decrypts the message. 10 | const ReadSize = lnwire.MaxSliceLength + 16 11 | 12 | // Read is a static byte array sized to the maximum-allowed Lightning message 13 | // size, plus 16 bytes for the MAC. 14 | type Read [ReadSize]byte 15 | 16 | // Recycle zeroes the Read, making it fresh for another use. 17 | func (b *Read) Recycle() { 18 | RecycleSlice(b[:]) 19 | } 20 | -------------------------------------------------------------------------------- /buffer/utils.go: -------------------------------------------------------------------------------- 1 | package buffer 2 | 3 | // RecycleSlice zeroes byte slice, making it fresh for another use. 4 | // Zeroing the buffer using a logarithmic number of calls to the optimized copy 5 | // method. Benchmarking shows this to be ~30 times faster than a for loop that 6 | // sets each index to 0 for ~65KB buffers use for wire messages. Inspired by: 7 | // https://stackoverflow.com/questions/30614165/is-there-analog-of-memset-in-go 8 | func RecycleSlice(b []byte) { 9 | if len(b) == 0 { 10 | return 11 | } 12 | 13 | b[0] = 0 14 | for i := 1; i < len(b); i *= 2 { 15 | copy(b[i:], b[:i]) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /buffer/write.go: -------------------------------------------------------------------------------- 1 | package buffer 2 | 3 | import ( 4 | "github.com/lightningnetwork/lnd/lnwire" 5 | ) 6 | 7 | // WriteSize represents the size of the maximum plaintext message than can be 8 | // sent using brontide. The buffer does not include extra space for the MAC, as 9 | // that is applied by the Noise protocol after encrypting the plaintext. 10 | const WriteSize = lnwire.MaxSliceLength 11 | 12 | // Write is static byte array occupying to maximum-allowed plaintext-message 13 | // size. 14 | type Write [WriteSize]byte 15 | 16 | // Recycle zeroes the Write, making it fresh for another use. 17 | func (b *Write) Recycle() { 18 | RecycleSlice(b[:]) 19 | } 20 | -------------------------------------------------------------------------------- /build/config_prod.go: -------------------------------------------------------------------------------- 1 | //go:build !dev 2 | // +build !dev 3 | 4 | package build 5 | 6 | // consoleLoggerCfg embeds the LoggerConfig struct along with any extensions 7 | // specific to a production deployment. 8 | // 9 | //nolint:ll 10 | type consoleLoggerCfg struct { 11 | *LoggerConfig `yaml:",inline"` 12 | } 13 | 14 | // defaultConsoleLoggerCfg returns the default consoleLoggerCfg for the prod 15 | // console logger. 16 | func defaultConsoleLoggerCfg() *consoleLoggerCfg { 17 | return &consoleLoggerCfg{ 18 | LoggerConfig: &LoggerConfig{ 19 | CallSite: callSiteOff, 20 | }, 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /build/dependencies.go: -------------------------------------------------------------------------------- 1 | //go:build buildtagdoesnotexist 2 | // +build buildtagdoesnotexist 3 | 4 | package build 5 | 6 | // This file is a workaround to make sure go mod keeps around the btcd 7 | // dependencies in the go.sum file that we only use during certain tasks (such 8 | // as integration tests or fuzzing) or only for certain operating systems. For 9 | // example, the specific btcd import makes sure the indirect dependency 10 | // github.com/btcsuite/winsvc is kept in the go.sum file. Because of the build 11 | // tag, this dependency never ends up in the final lnd binary. 12 | import ( 13 | _ "github.com/btcsuite/btcd" 14 | ) 15 | -------------------------------------------------------------------------------- /build/deployment.go: -------------------------------------------------------------------------------- 1 | package build 2 | 3 | // DeploymentType is an enum specifying the deployment to compile. 4 | type DeploymentType byte 5 | 6 | const ( 7 | // Development is a deployment that includes extra testing hooks and 8 | // logging configurations. 9 | Development DeploymentType = iota 10 | 11 | // Production is a deployment that strips out testing logic and uses 12 | // Default logging. 13 | Production 14 | ) 15 | 16 | // String returns a human readable name for a build type. 17 | func (b DeploymentType) String() string { 18 | switch b { 19 | case Development: 20 | return "development" 21 | case Production: 22 | return "production" 23 | default: 24 | return "unknown" 25 | } 26 | } 27 | 28 | // IsProdBuild returns true if this is a production build. 29 | func IsProdBuild() bool { 30 | return Deployment == Production 31 | } 32 | 33 | // IsDevBuild returns true if this is a development build. 34 | func IsDevBuild() bool { 35 | return Deployment == Development 36 | } 37 | -------------------------------------------------------------------------------- /build/deployment_dev.go: -------------------------------------------------------------------------------- 1 | //go:build dev 2 | // +build dev 3 | 4 | package build 5 | 6 | // Deployment specifies a development build. 7 | const Deployment = Development 8 | -------------------------------------------------------------------------------- /build/deployment_prod.go: -------------------------------------------------------------------------------- 1 | //go:build !dev 2 | // +build !dev 3 | 4 | package build 5 | 6 | // Deployment specifies a production build. 7 | const Deployment = Production 8 | -------------------------------------------------------------------------------- /build/log_default.go: -------------------------------------------------------------------------------- 1 | //go:build !stdlog && !nolog 2 | // +build !stdlog,!nolog 3 | 4 | package build 5 | 6 | // LoggingType is a log type that writes to both stdout and the log rotator, if 7 | // present. 8 | const LoggingType = LogTypeDefault 9 | -------------------------------------------------------------------------------- /build/log_nolog.go: -------------------------------------------------------------------------------- 1 | //go:build nolog 2 | // +build nolog 3 | 4 | package build 5 | 6 | // LoggingType is a log type that writes no logs. 7 | const LoggingType = LogTypeNone 8 | -------------------------------------------------------------------------------- /build/log_stdlog.go: -------------------------------------------------------------------------------- 1 | //go:build stdlog 2 | // +build stdlog 3 | 4 | package build 5 | 6 | // LoggingType is a log type that only writes to stdout. 7 | const LoggingType = LogTypeStdOut 8 | -------------------------------------------------------------------------------- /build/loglevel_critical.go: -------------------------------------------------------------------------------- 1 | //go:build dev && critical 2 | // +build dev,critical 3 | 4 | package build 5 | 6 | // LogLevel specifies a critical log level. 7 | var LogLevel = "critical" 8 | -------------------------------------------------------------------------------- /build/loglevel_debug.go: -------------------------------------------------------------------------------- 1 | //go:build dev && debug 2 | // +build dev,debug 3 | 4 | package build 5 | 6 | // LogLevel specifies a debug log level. 7 | var LogLevel = "debug" 8 | -------------------------------------------------------------------------------- /build/loglevel_default.go: -------------------------------------------------------------------------------- 1 | //go:build !info && !debug && !trace && !warn && !error && !critical && !off 2 | // +build !info,!debug,!trace,!warn,!error,!critical,!off 3 | 4 | package build 5 | 6 | // LogLevel specifies a default log level of info. 7 | var LogLevel = "info" 8 | -------------------------------------------------------------------------------- /build/loglevel_error.go: -------------------------------------------------------------------------------- 1 | //go:build dev && error 2 | // +build dev,error 3 | 4 | package build 5 | 6 | // LogLevel specifies an error log level. 7 | var LogLevel = "error" 8 | -------------------------------------------------------------------------------- /build/loglevel_info.go: -------------------------------------------------------------------------------- 1 | //go:build dev && info 2 | // +build dev,info 3 | 4 | package build 5 | 6 | // LogLevel specifies an info log level. 7 | var LogLevel = "info" 8 | -------------------------------------------------------------------------------- /build/loglevel_off.go: -------------------------------------------------------------------------------- 1 | //go:build dev && off 2 | // +build dev,off 3 | 4 | package build 5 | 6 | // LogLevel specifies an off log level. 7 | var LogLevel = "off" 8 | -------------------------------------------------------------------------------- /build/loglevel_trace.go: -------------------------------------------------------------------------------- 1 | //go:build dev && trace 2 | // +build dev,trace 3 | 4 | package build 5 | 6 | // LogLevel specifies a trace log level. 7 | var LogLevel = "trace" 8 | -------------------------------------------------------------------------------- /build/loglevel_warn.go: -------------------------------------------------------------------------------- 1 | //go:build dev && warn 2 | // +build dev,warn 3 | 4 | package build 5 | 6 | // LogLevel specifies a warning log level. 7 | var LogLevel = "warn" 8 | -------------------------------------------------------------------------------- /cert/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/lightningnetwork/lnd/cert 2 | 3 | go 1.19 4 | 5 | require github.com/stretchr/testify v1.8.2 6 | 7 | require ( 8 | github.com/davecgh/go-spew v1.1.1 // indirect 9 | github.com/kr/pretty v0.3.0 // indirect 10 | github.com/pmezard/go-difflib v1.0.0 // indirect 11 | github.com/rogpeppe/go-internal v1.9.0 // indirect 12 | gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect 13 | gopkg.in/yaml.v3 v3.0.1 // indirect 14 | ) 15 | -------------------------------------------------------------------------------- /chainio/blockbeat_test.go: -------------------------------------------------------------------------------- 1 | package chainio 2 | 3 | import ( 4 | "errors" 5 | "testing" 6 | 7 | "github.com/lightningnetwork/lnd/chainntnfs" 8 | "github.com/stretchr/testify/require" 9 | ) 10 | 11 | var errDummy = errors.New("dummy error") 12 | 13 | // TestNewBeat tests the NewBeat and Height functions. 14 | func TestNewBeat(t *testing.T) { 15 | t.Parallel() 16 | 17 | // Create a testing epoch. 18 | epoch := chainntnfs.BlockEpoch{ 19 | Height: 1, 20 | } 21 | 22 | // Create the beat and check the internal state. 23 | beat := NewBeat(epoch) 24 | require.Equal(t, epoch, beat.epoch) 25 | 26 | // Check the height function. 27 | require.Equal(t, epoch.Height, beat.Height()) 28 | } 29 | -------------------------------------------------------------------------------- /chainio/log.go: -------------------------------------------------------------------------------- 1 | package chainio 2 | 3 | import ( 4 | "github.com/btcsuite/btclog/v2" 5 | "github.com/lightningnetwork/lnd/build" 6 | ) 7 | 8 | // Subsystem defines the logging code for this subsystem. 9 | const Subsystem = "CHIO" 10 | 11 | // clog is a logger that is initialized with no output filters. This means the 12 | // package will not perform any logging by default until the caller requests 13 | // it. 14 | var clog btclog.Logger 15 | 16 | // The default amount of logging is none. 17 | func init() { 18 | UseLogger(build.NewSubLogger(Subsystem, nil)) 19 | } 20 | 21 | // DisableLog disables all library log output. Logging output is disabled by 22 | // default until UseLogger is called. 23 | func DisableLog() { 24 | UseLogger(btclog.Disabled) 25 | } 26 | 27 | // UseLogger uses a specified Logger to output package logging info. This 28 | // should be used in preference to SetLogWriter if the caller is also using 29 | // btclog. 30 | func UseLogger(logger btclog.Logger) { 31 | clog = logger 32 | } 33 | -------------------------------------------------------------------------------- /chainntnfs/errors.go: -------------------------------------------------------------------------------- 1 | package chainntnfs 2 | 3 | import "errors" 4 | 5 | var ( 6 | // ErrCorruptedHeightHintCache indicates that the on-disk representation 7 | // has altered since the height hint cache instance was initialized. 8 | ErrCorruptedHeightHintCache = errors.New("height hint cache has been " + 9 | "corrupted") 10 | 11 | // ErrSpendHintNotFound is an error returned when a spend hint for an 12 | // outpoint was not found. 13 | ErrSpendHintNotFound = errors.New("spend hint not found") 14 | 15 | // ErrConfirmHintNotFound is an error returned when a confirm hint for a 16 | // transaction was not found. 17 | ErrConfirmHintNotFound = errors.New("confirm hint not found") 18 | ) 19 | -------------------------------------------------------------------------------- /chainntnfs/interface_dev.go: -------------------------------------------------------------------------------- 1 | //go:build dev 2 | // +build dev 3 | 4 | package chainntnfs 5 | 6 | import "github.com/btcsuite/btcd/chaincfg/chainhash" 7 | 8 | // TestChainNotifier enables the use of methods that are only present during 9 | // testing for ChainNotifiers. 10 | type TestChainNotifier interface { 11 | ChainNotifier 12 | 13 | // UnsafeStart enables notifiers to start up with a specific best block. 14 | // Used for testing. 15 | UnsafeStart(int32, *chainhash.Hash, int32, func() error) error 16 | } 17 | -------------------------------------------------------------------------------- /chainntnfs/log.go: -------------------------------------------------------------------------------- 1 | package chainntnfs 2 | 3 | import ( 4 | "github.com/btcsuite/btclog/v2" 5 | "github.com/lightningnetwork/lnd/build" 6 | ) 7 | 8 | // Log is a logger that is initialized with no output filters. This 9 | // means the package will not perform any logging by default until the caller 10 | // requests it. 11 | var Log btclog.Logger 12 | 13 | // The default amount of logging is none. 14 | func init() { 15 | UseLogger(build.NewSubLogger("NTFN", nil)) 16 | } 17 | 18 | // DisableLog disables all library log output. Logging output is disabled 19 | // by default until UseLogger is called. 20 | func DisableLog() { 21 | UseLogger(btclog.Disabled) 22 | } 23 | 24 | // UseLogger uses a specified Logger to output package logging info. 25 | // This should be used in preference to SetLogWriter if the caller is also 26 | // using btclog. 27 | func UseLogger(logger btclog.Logger) { 28 | Log = logger 29 | } 30 | -------------------------------------------------------------------------------- /chainntnfs/test/bitcoind/bitcoind_test.go: -------------------------------------------------------------------------------- 1 | //go:build dev 2 | // +build dev 3 | 4 | package bitcoind_test 5 | 6 | import ( 7 | "testing" 8 | 9 | chainntnfstest "github.com/lightningnetwork/lnd/chainntnfs/test" 10 | ) 11 | 12 | // TestInterfaces executes the generic notifier test suite against a bitcoind 13 | // powered chain notifier. 14 | func TestInterfaces(t *testing.T) { 15 | success := t.Run("bitcoind", func(st *testing.T) { 16 | st.Parallel() 17 | chainntnfstest.TestInterfaces(st, "bitcoind") 18 | }) 19 | 20 | if !success { 21 | return 22 | } 23 | 24 | t.Run("bitcoind rpc polling", func(st *testing.T) { 25 | st.Parallel() 26 | chainntnfstest.TestInterfaces(st, "bitcoind-rpc-polling") 27 | }) 28 | } 29 | -------------------------------------------------------------------------------- /chainntnfs/test/btcd/btcd_test.go: -------------------------------------------------------------------------------- 1 | //go:build dev 2 | // +build dev 3 | 4 | package btcd_test 5 | 6 | import ( 7 | "testing" 8 | 9 | chainntnfstest "github.com/lightningnetwork/lnd/chainntnfs/test" 10 | ) 11 | 12 | // TestInterfaces executes the generic notifier test suite against a btcd 13 | // powered chain notifier. 14 | func TestInterfaces(t *testing.T) { 15 | chainntnfstest.TestInterfaces(t, "btcd") 16 | } 17 | -------------------------------------------------------------------------------- /chainntnfs/test/neutrino/neutrino_test.go: -------------------------------------------------------------------------------- 1 | //go:build dev 2 | // +build dev 3 | 4 | package neutrino_test 5 | 6 | import ( 7 | "testing" 8 | 9 | chainntnfstest "github.com/lightningnetwork/lnd/chainntnfs/test" 10 | ) 11 | 12 | // TestInterfaces executes the generic notifier test suite against a neutrino 13 | // powered chain notifier. 14 | func TestInterfaces(t *testing.T) { 15 | chainntnfstest.TestInterfaces(t, "neutrino") 16 | } 17 | -------------------------------------------------------------------------------- /chainreg/log.go: -------------------------------------------------------------------------------- 1 | package chainreg 2 | 3 | import ( 4 | "github.com/btcsuite/btclog/v2" 5 | "github.com/lightningnetwork/lnd/build" 6 | ) 7 | 8 | // Subsystem defines the logging code for this subsystem. 9 | const Subsystem = "CHRE" 10 | 11 | // log is a logger that is initialized with the btclog.Disabled logger. 12 | var log btclog.Logger 13 | 14 | // The default amount of logging is none. 15 | func init() { 16 | UseLogger(build.NewSubLogger(Subsystem, nil)) 17 | } 18 | 19 | // DisableLog disables all logging output. 20 | func DisableLog() { 21 | UseLogger(btclog.Disabled) 22 | } 23 | 24 | // UseLogger uses a specified Logger to output package logging info. 25 | func UseLogger(logger btclog.Logger) { 26 | log = logger 27 | } 28 | -------------------------------------------------------------------------------- /chanacceptor/errors.go: -------------------------------------------------------------------------------- 1 | package chanacceptor 2 | 3 | // ChanAcceptError is an error that it returned when an external channel 4 | // acceptor rejects a channel. Note that this error type is whitelisted and will 5 | // be delivered to the peer initiating a channel. 6 | type ChanAcceptError struct { 7 | error 8 | } 9 | -------------------------------------------------------------------------------- /chanacceptor/log.go: -------------------------------------------------------------------------------- 1 | package chanacceptor 2 | 3 | import ( 4 | "github.com/btcsuite/btclog/v2" 5 | "github.com/lightningnetwork/lnd/build" 6 | ) 7 | 8 | // Subsystem defines the logging code for this subsystem. 9 | const Subsystem = "CHAC" 10 | 11 | // log is a logger that is initialized with no output filters. This 12 | // means the package will not perform any logging by default until the caller 13 | // requests it. 14 | var log btclog.Logger 15 | 16 | // The default amount of logging is none. 17 | func init() { 18 | UseLogger(build.NewSubLogger(Subsystem, nil)) 19 | } 20 | 21 | // DisableLog disables all library log output. Logging output is disabled 22 | // by default until UseLogger is called. 23 | func DisableLog() { 24 | UseLogger(btclog.Disabled) 25 | } 26 | 27 | // UseLogger uses a specified Logger to output package logging info. 28 | // This should be used in preference to SetLogWriter if the caller is also 29 | // using btclog. 30 | func UseLogger(logger btclog.Logger) { 31 | log = logger 32 | } 33 | -------------------------------------------------------------------------------- /chanbackup/log.go: -------------------------------------------------------------------------------- 1 | package chanbackup 2 | 3 | import ( 4 | "github.com/btcsuite/btclog/v2" 5 | "github.com/lightningnetwork/lnd/build" 6 | ) 7 | 8 | // log is a logger that is initialized with no output filters. This 9 | // means the package will not perform any logging by default until the caller 10 | // requests it. 11 | var log btclog.Logger 12 | 13 | // The default amount of logging is none. 14 | func init() { 15 | UseLogger(build.NewSubLogger("CHBU", nil)) 16 | } 17 | 18 | // DisableLog disables all library log output. Logging output is disabled 19 | // by default until UseLogger is called. 20 | func DisableLog() { 21 | UseLogger(btclog.Disabled) 22 | } 23 | 24 | // UseLogger uses a specified Logger to output package logging info. 25 | // This should be used in preference to SetLogWriter if the caller is also 26 | // using btclog. 27 | func UseLogger(logger btclog.Logger) { 28 | log = logger 29 | } 30 | -------------------------------------------------------------------------------- /chanfitness/log.go: -------------------------------------------------------------------------------- 1 | package chanfitness 2 | 3 | import ( 4 | "github.com/btcsuite/btclog/v2" 5 | "github.com/lightningnetwork/lnd/build" 6 | ) 7 | 8 | // Subsystem defines the logging code for this subsystem. 9 | const Subsystem = "CHFT" 10 | 11 | // log is a logger that is initialized with no output filters. This 12 | // means the package will not perform any logging by default until the caller 13 | // requests it. 14 | var log btclog.Logger 15 | 16 | // The default amount of logging is none. 17 | func init() { 18 | UseLogger(build.NewSubLogger(Subsystem, nil)) 19 | } 20 | 21 | // DisableLog disables all library log output. Logging output is disabled 22 | // by default until UseLogger is called. 23 | func DisableLog() { 24 | UseLogger(btclog.Disabled) 25 | } 26 | 27 | // UseLogger uses a specified Logger to output package logging info. 28 | // This should be used in preference to SetLogWriter if the caller is also 29 | // using btclog. 30 | func UseLogger(logger btclog.Logger) { 31 | log = logger 32 | } 33 | -------------------------------------------------------------------------------- /channeldb/migration/create_tlb.go: -------------------------------------------------------------------------------- 1 | package migration 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/lightningnetwork/lnd/kvdb" 7 | ) 8 | 9 | // CreateTLB creates a new top-level bucket with the passed bucket identifier. 10 | func CreateTLB(bucket []byte) func(kvdb.RwTx) error { 11 | return func(tx kvdb.RwTx) error { 12 | log.Infof("Creating top-level bucket: \"%s\" ...", bucket) 13 | 14 | if tx.ReadBucket(bucket) != nil { 15 | return fmt.Errorf("top-level bucket \"%s\" "+ 16 | "already exists", bucket) 17 | } 18 | 19 | _, err := tx.CreateTopLevelBucket(bucket) 20 | if err != nil { 21 | return err 22 | } 23 | 24 | log.Infof("Created top-level bucket: \"%s\"", bucket) 25 | return nil 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /channeldb/migration/log.go: -------------------------------------------------------------------------------- 1 | package migration 2 | 3 | import "github.com/btcsuite/btclog/v2" 4 | 5 | // log is a logger that is initialized as disabled. This means the package will 6 | // not perform any logging by default until a logger is set. 7 | var log = btclog.Disabled 8 | 9 | // UseLogger uses a specified Logger to output package logging info. 10 | func UseLogger(logger btclog.Logger) { 11 | log = logger 12 | } 13 | -------------------------------------------------------------------------------- /channeldb/migration12/log.go: -------------------------------------------------------------------------------- 1 | package migration12 2 | 3 | import ( 4 | "github.com/btcsuite/btclog/v2" 5 | ) 6 | 7 | // log is a logger that is initialized as disabled. This means the package will 8 | // not perform any logging by default until a logger is set. 9 | var log = btclog.Disabled 10 | 11 | // UseLogger uses a specified Logger to output package logging info. 12 | func UseLogger(logger btclog.Logger) { 13 | log = logger 14 | } 15 | -------------------------------------------------------------------------------- /channeldb/migration13/log.go: -------------------------------------------------------------------------------- 1 | package migration13 2 | 3 | import ( 4 | "github.com/btcsuite/btclog/v2" 5 | ) 6 | 7 | // log is a logger that is initialized as disabled. This means the package will 8 | // not perform any logging by default until a logger is set. 9 | var log = btclog.Disabled 10 | 11 | // UseLogger uses a specified Logger to output package logging info. 12 | func UseLogger(logger btclog.Logger) { 13 | log = logger 14 | } 15 | -------------------------------------------------------------------------------- /channeldb/migration16/log.go: -------------------------------------------------------------------------------- 1 | package migration16 2 | 3 | import ( 4 | "github.com/btcsuite/btclog/v2" 5 | ) 6 | 7 | // log is a logger that is initialized as disabled. This means the package will 8 | // not perform any logging by default until a logger is set. 9 | var log = btclog.Disabled 10 | 11 | // UseLogger uses a specified Logger to output package logging info. 12 | func UseLogger(logger btclog.Logger) { 13 | log = logger 14 | } 15 | -------------------------------------------------------------------------------- /channeldb/migration20/codec.go: -------------------------------------------------------------------------------- 1 | package migration20 2 | 3 | import ( 4 | "encoding/binary" 5 | "io" 6 | 7 | "github.com/btcsuite/btcd/wire" 8 | ) 9 | 10 | var ( 11 | byteOrder = binary.BigEndian 12 | ) 13 | 14 | // writeOutpoint writes an outpoint from the passed writer. 15 | func writeOutpoint(w io.Writer, o *wire.OutPoint) error { 16 | if _, err := w.Write(o.Hash[:]); err != nil { 17 | return err 18 | } 19 | if err := binary.Write(w, byteOrder, o.Index); err != nil { 20 | return err 21 | } 22 | 23 | return nil 24 | } 25 | 26 | // readOutpoint reads an outpoint from the passed reader. 27 | func readOutpoint(r io.Reader, o *wire.OutPoint) error { 28 | if _, err := io.ReadFull(r, o.Hash[:]); err != nil { 29 | return err 30 | } 31 | if err := binary.Read(r, byteOrder, &o.Index); err != nil { 32 | return err 33 | } 34 | 35 | return nil 36 | } 37 | -------------------------------------------------------------------------------- /channeldb/migration20/log.go: -------------------------------------------------------------------------------- 1 | package migration20 2 | 3 | import ( 4 | "github.com/btcsuite/btclog/v2" 5 | ) 6 | 7 | // log is a logger that is initialized as disabled. This means the package 8 | // will not perform any logging by default until a logger is set. 9 | var log = btclog.Disabled 10 | 11 | // UseLogger uses a specified Logger to output package logging info. 12 | func UseLogger(logger btclog.Logger) { 13 | log = logger 14 | } 15 | -------------------------------------------------------------------------------- /channeldb/migration24/log.go: -------------------------------------------------------------------------------- 1 | package migration24 2 | 3 | import ( 4 | "github.com/btcsuite/btclog/v2" 5 | ) 6 | 7 | // log is a logger that is initialized as disabled. This means the package will 8 | // not perform any logging by default until a logger is set. 9 | var log = btclog.Disabled 10 | 11 | // UseLogger uses a specified Logger to output package logging info. 12 | func UseLogger(logger btclog.Logger) { 13 | log = logger 14 | } 15 | -------------------------------------------------------------------------------- /channeldb/migration25/log.go: -------------------------------------------------------------------------------- 1 | package migration25 2 | 3 | import ( 4 | "github.com/btcsuite/btclog/v2" 5 | ) 6 | 7 | // log is a logger that is initialized as disabled. This means the package will 8 | // not perform any logging by default until a logger is set. 9 | var log = btclog.Disabled 10 | 11 | // UseLogger uses a specified Logger to output package logging info. 12 | func UseLogger(logger btclog.Logger) { 13 | log = logger 14 | } 15 | -------------------------------------------------------------------------------- /channeldb/migration26/log.go: -------------------------------------------------------------------------------- 1 | package migration26 2 | 3 | import ( 4 | "github.com/btcsuite/btclog/v2" 5 | ) 6 | 7 | // log is a logger that is initialized as disabled. This means the package will 8 | // not perform any logging by default until a logger is set. 9 | var log = btclog.Disabled 10 | 11 | // UseLogger uses a specified Logger to output package logging info. 12 | func UseLogger(logger btclog.Logger) { 13 | log = logger 14 | } 15 | -------------------------------------------------------------------------------- /channeldb/migration27/log.go: -------------------------------------------------------------------------------- 1 | package migration27 2 | 3 | import ( 4 | "github.com/btcsuite/btclog/v2" 5 | ) 6 | 7 | // log is a logger that is initialized as disabled. This means the package will 8 | // not perform any logging by default until a logger is set. 9 | var log = btclog.Disabled 10 | 11 | // UseLogger uses a specified Logger to output package logging info. 12 | func UseLogger(logger btclog.Logger) { 13 | log = logger 14 | } 15 | -------------------------------------------------------------------------------- /channeldb/migration29/log.go: -------------------------------------------------------------------------------- 1 | package migration29 2 | 3 | import "github.com/btcsuite/btclog/v2" 4 | 5 | // log is a logger that is initialized as disabled. This means the package will 6 | // not perform any logging by default until a logger is set. 7 | var log = btclog.Disabled 8 | 9 | // UseLogger uses a specific Logger to output package logging info. 10 | func UseLogger(logger btclog.Logger) { 11 | log = logger 12 | } 13 | -------------------------------------------------------------------------------- /channeldb/migration30/log.go: -------------------------------------------------------------------------------- 1 | package migration30 2 | 3 | import ( 4 | "github.com/btcsuite/btclog/v2" 5 | ) 6 | 7 | // log is a logger that is initialized as disabled. This means the package will 8 | // not perform any logging by default until a logger is set. 9 | var log = btclog.Disabled 10 | 11 | // UseLogger uses a specified Logger to output package logging info. 12 | func UseLogger(logger btclog.Logger) { 13 | log = logger 14 | } 15 | -------------------------------------------------------------------------------- /channeldb/migration31/log.go: -------------------------------------------------------------------------------- 1 | package migration31 2 | 3 | import ( 4 | "github.com/btcsuite/btclog/v2" 5 | ) 6 | 7 | // log is a logger that is initialized as disabled. This means the package will 8 | // not perform any logging by default until a logger is set. 9 | var log = btclog.Disabled 10 | 11 | // UseLogger uses a specified Logger to output package logging info. 12 | func UseLogger(logger btclog.Logger) { 13 | log = logger 14 | } 15 | -------------------------------------------------------------------------------- /channeldb/migration31/migration.go: -------------------------------------------------------------------------------- 1 | package migration31 2 | 3 | import ( 4 | "errors" 5 | 6 | "github.com/btcsuite/btcwallet/walletdb" 7 | "github.com/lightningnetwork/lnd/kvdb" 8 | ) 9 | 10 | // DeleteLastPublishedTxTLB deletes the top level bucket with the key 11 | // "sweeper-last-tx". 12 | func DeleteLastPublishedTxTLB(tx kvdb.RwTx) error { 13 | log.Infof("Deleting top-level bucket: %x ...", lastTxBucketKey) 14 | 15 | err := tx.DeleteTopLevelBucket(lastTxBucketKey) 16 | if err != nil && !errors.Is(err, walletdb.ErrBucketNotFound) { 17 | return err 18 | } 19 | 20 | log.Infof("Deleted top-level bucket: %x", lastTxBucketKey) 21 | 22 | return nil 23 | } 24 | -------------------------------------------------------------------------------- /channeldb/migration31/store.go: -------------------------------------------------------------------------------- 1 | package migration31 2 | 3 | var ( 4 | // lastTxBucketKey is the key that points to a bucket containing a 5 | // single item storing the last published sweep tx. 6 | // 7 | // maps: lastTxKey -> serialized_tx 8 | lastTxBucketKey = []byte("sweeper-last-tx") 9 | ) 10 | -------------------------------------------------------------------------------- /channeldb/migration32/log.go: -------------------------------------------------------------------------------- 1 | package migration32 2 | 3 | import ( 4 | "github.com/btcsuite/btclog/v2" 5 | ) 6 | 7 | // log is a logger that is initialized as disabled. This means the package will 8 | // not perform any logging by default until a logger is set. 9 | var log = btclog.Disabled 10 | 11 | // UseLogger uses a specified Logger to output package logging info. 12 | func UseLogger(logger btclog.Logger) { 13 | log = logger 14 | } 15 | -------------------------------------------------------------------------------- /channeldb/migration33/log.go: -------------------------------------------------------------------------------- 1 | package migration33 2 | 3 | import ( 4 | "github.com/btcsuite/btclog/v2" 5 | ) 6 | 7 | // log is a logger that is initialized as disabled. This means the package will 8 | // not perform any logging by default until a logger is set. 9 | var log = btclog.Disabled 10 | 11 | // UseLogger uses a specified Logger to output package logging info. 12 | func UseLogger(logger btclog.Logger) { 13 | log = logger 14 | } 15 | -------------------------------------------------------------------------------- /channeldb/migration_01_to_11/log.go: -------------------------------------------------------------------------------- 1 | package migration_01_to_11 2 | 3 | import ( 4 | "github.com/btcsuite/btclog/v2" 5 | ) 6 | 7 | // log is a logger that is initialized as disabled. This means the package will 8 | // not perform any logging by default until a logger is set. 9 | var log = btclog.Disabled 10 | 11 | // UseLogger uses a specified Logger to output package logging info. 12 | func UseLogger(logger btclog.Logger) { 13 | log = logger 14 | } 15 | -------------------------------------------------------------------------------- /channeldb/migration_01_to_11/payment_control.go: -------------------------------------------------------------------------------- 1 | package migration_01_to_11 2 | 3 | import "github.com/lightningnetwork/lnd/kvdb" 4 | 5 | // fetchPaymentStatus fetches the payment status of the payment. If the payment 6 | // isn't found, it will default to "StatusUnknown". 7 | func fetchPaymentStatus(bucket kvdb.RBucket) PaymentStatus { 8 | if bucket.Get(paymentSettleInfoKey) != nil { 9 | return StatusSucceeded 10 | } 11 | 12 | if bucket.Get(paymentFailInfoKey) != nil { 13 | return StatusFailed 14 | } 15 | 16 | if bucket.Get(paymentCreationInfoKey) != nil { 17 | return StatusInFlight 18 | } 19 | 20 | return StatusUnknown 21 | } 22 | -------------------------------------------------------------------------------- /channeldb/setup_test.go: -------------------------------------------------------------------------------- 1 | package channeldb 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/lightningnetwork/lnd/kvdb" 7 | ) 8 | 9 | func TestMain(m *testing.M) { 10 | kvdb.RunTests(m) 11 | } 12 | -------------------------------------------------------------------------------- /channelnotifier/log.go: -------------------------------------------------------------------------------- 1 | package channelnotifier 2 | 3 | import ( 4 | "github.com/btcsuite/btclog/v2" 5 | "github.com/lightningnetwork/lnd/build" 6 | ) 7 | 8 | // log is a logger that is initialized with no output filters. This means the 9 | // package will not perform any logging by default until the caller requests 10 | // it. 11 | var log btclog.Logger 12 | 13 | // The default amount of logging is none. 14 | func init() { 15 | UseLogger(build.NewSubLogger("CHNF", nil)) 16 | } 17 | 18 | // DisableLog disables all library log output. Logging output is disabled by 19 | // default until UseLogger is called. 20 | func DisableLog() { 21 | UseLogger(btclog.Disabled) 22 | } 23 | 24 | // UseLogger uses a specified Logger to output package logging info. This 25 | // should be used in preference to SetLogWriter if the caller is also using 26 | // btclog. 27 | func UseLogger(logger btclog.Logger) { 28 | log = logger 29 | } 30 | -------------------------------------------------------------------------------- /clock/default_clock.go: -------------------------------------------------------------------------------- 1 | package clock 2 | 3 | import ( 4 | "time" 5 | ) 6 | 7 | // DefaultClock implements Clock interface by simply calling the appropriate 8 | // time functions. 9 | type DefaultClock struct{} 10 | 11 | // NewDefaultClock constructs a new DefaultClock. 12 | func NewDefaultClock() Clock { 13 | return &DefaultClock{} 14 | } 15 | 16 | // Now simply returns time.Now(). 17 | func (DefaultClock) Now() time.Time { 18 | return time.Now() 19 | } 20 | 21 | // TickAfter simply wraps time.After(). 22 | func (DefaultClock) TickAfter(duration time.Duration) <-chan time.Time { 23 | return time.After(duration) 24 | } 25 | -------------------------------------------------------------------------------- /clock/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/lightningnetwork/lnd/clock 2 | 3 | go 1.19 4 | 5 | require github.com/stretchr/testify v1.8.2 6 | 7 | require ( 8 | github.com/davecgh/go-spew v1.1.1 // indirect 9 | github.com/kr/pretty v0.3.0 // indirect 10 | github.com/pmezard/go-difflib v1.0.0 // indirect 11 | github.com/rogpeppe/go-internal v1.9.0 // indirect 12 | gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect 13 | gopkg.in/yaml.v3 v3.0.1 // indirect 14 | ) 15 | -------------------------------------------------------------------------------- /clock/interface.go: -------------------------------------------------------------------------------- 1 | package clock 2 | 3 | import ( 4 | "time" 5 | ) 6 | 7 | // Clock is an interface that provides a time functions for LND packages. 8 | // This is useful during testing when a concrete time reference is needed. 9 | type Clock interface { 10 | // Now returns the current local time (as defined by the Clock). 11 | Now() time.Time 12 | 13 | // TickAfter returns a channel that will receive a tick after the specified 14 | // duration has passed. 15 | TickAfter(duration time.Duration) <-chan time.Time 16 | } 17 | -------------------------------------------------------------------------------- /cluster/interface.go: -------------------------------------------------------------------------------- 1 | package cluster 2 | 3 | import ( 4 | "context" 5 | ) 6 | 7 | const ( 8 | // EtcdLeaderElector is the id used when constructing an 9 | // etcdLeaderElector instance through the factory. 10 | EtcdLeaderElector = "etcd" 11 | ) 12 | 13 | // LeaderElector is a general interface implementing basic leader elections 14 | // in a clustered environment. 15 | type LeaderElector interface { 16 | // Campaign starts a run for leadership. Campaign will block until 17 | // the caller is elected as the leader. 18 | Campaign(ctx context.Context) error 19 | 20 | // Resign resigns from the leader role, allowing other election members 21 | // to take on leadership. 22 | Resign(ctx context.Context) error 23 | 24 | // Leader returns the leader value for the current election. 25 | Leader(ctx context.Context) (string, error) 26 | 27 | // IsLeader returns true if the caller is the leader. 28 | IsLeader(ctx context.Context) (bool, error) 29 | } 30 | -------------------------------------------------------------------------------- /cluster/log.go: -------------------------------------------------------------------------------- 1 | package cluster 2 | 3 | import ( 4 | "github.com/btcsuite/btclog/v2" 5 | "github.com/lightningnetwork/lnd/build" 6 | ) 7 | 8 | // Subsystem defines the logging code for this subsystem. 9 | const Subsystem = "CLUS" 10 | 11 | // log is a logger that is initialized with the btclog.Disabled logger. 12 | var log btclog.Logger 13 | 14 | // The default amount of logging is none. 15 | func init() { 16 | UseLogger(build.NewSubLogger(Subsystem, nil)) 17 | } 18 | 19 | // DisableLog disables all logging output. 20 | func DisableLog() { 21 | UseLogger(btclog.Disabled) 22 | } 23 | 24 | // UseLogger uses a specified Logger to output package logging info. 25 | func UseLogger(logger btclog.Logger) { 26 | log = logger 27 | } 28 | -------------------------------------------------------------------------------- /cmd/commands/autopilotrpc_default.go: -------------------------------------------------------------------------------- 1 | //go:build !autopilotrpc 2 | // +build !autopilotrpc 3 | 4 | package commands 5 | 6 | import "github.com/urfave/cli" 7 | 8 | // autopilotCommands will return nil for non-autopilotrpc builds. 9 | func autopilotCommands() []cli.Command { 10 | return nil 11 | } 12 | -------------------------------------------------------------------------------- /cmd/commands/chainrpc_default.go: -------------------------------------------------------------------------------- 1 | //go:build !chainrpc 2 | // +build !chainrpc 3 | 4 | package commands 5 | 6 | import "github.com/urfave/cli" 7 | 8 | // chainCommands will return nil for non-chainrpc builds. 9 | func chainCommands() []cli.Command { 10 | return nil 11 | } 12 | -------------------------------------------------------------------------------- /cmd/commands/devrpc_default.go: -------------------------------------------------------------------------------- 1 | //go:build !dev 2 | // +build !dev 3 | 4 | package commands 5 | 6 | import "github.com/urfave/cli" 7 | 8 | // devCommands will return nil for non-devrpc builds. 9 | func devCommands() []cli.Command { 10 | return nil 11 | } 12 | -------------------------------------------------------------------------------- /cmd/commands/invoicesrpc_default.go: -------------------------------------------------------------------------------- 1 | //go:build !invoicesrpc 2 | // +build !invoicesrpc 3 | 4 | package commands 5 | 6 | import "github.com/urfave/cli" 7 | 8 | // invoicesCommands will return nil for non-invoicesrpc builds. 9 | func invoicesCommands() []cli.Command { 10 | return nil 11 | } 12 | -------------------------------------------------------------------------------- /cmd/commands/neutrino_default.go: -------------------------------------------------------------------------------- 1 | //go:build !neutrinorpc 2 | // +build !neutrinorpc 3 | 4 | package commands 5 | 6 | import "github.com/urfave/cli" 7 | 8 | // neutrinoCommands will return nil for non-neutrinorpc builds. 9 | func neutrinoCommands() []cli.Command { 10 | return nil 11 | } 12 | -------------------------------------------------------------------------------- /cmd/commands/peersrpc_default.go: -------------------------------------------------------------------------------- 1 | //go:build !peersrpc 2 | // +build !peersrpc 3 | 4 | package commands 5 | 6 | import "github.com/urfave/cli" 7 | 8 | // peersCommands will return nil for non-peersrpc builds. 9 | func peersCommands() []cli.Command { 10 | return nil 11 | } 12 | -------------------------------------------------------------------------------- /cmd/commands/routerrpc.go: -------------------------------------------------------------------------------- 1 | package commands 2 | 3 | import "github.com/urfave/cli" 4 | 5 | // routerCommands returns a list of routerrpc commands. 6 | func routerCommands() []cli.Command { 7 | return []cli.Command{ 8 | queryMissionControlCommand, 9 | importMissionControlCommand, 10 | loadMissionControlCommand, 11 | queryProbCommand, 12 | resetMissionControlCommand, 13 | buildRouteCommand, 14 | getCfgCommand, 15 | setCfgCommand, 16 | updateChanStatusCommand, 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /cmd/commands/walletrpc_default.go: -------------------------------------------------------------------------------- 1 | //go:build !walletrpc 2 | // +build !walletrpc 3 | 4 | package commands 5 | 6 | import "github.com/urfave/cli" 7 | 8 | // walletCommands will return nil for non-walletrpc builds. 9 | func walletCommands() []cli.Command { 10 | return nil 11 | } 12 | -------------------------------------------------------------------------------- /cmd/commands/watchtower_default.go: -------------------------------------------------------------------------------- 1 | //go:build !watchtowerrpc 2 | // +build !watchtowerrpc 3 | 4 | package commands 5 | 6 | import "github.com/urfave/cli" 7 | 8 | // watchtowerCommands will return nil for non-watchtowerrpc builds. 9 | func watchtowerCommands() []cli.Command { 10 | return nil 11 | } 12 | -------------------------------------------------------------------------------- /cmd/lncli/main.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013-2017 The btcsuite developers 2 | // Copyright (c) 2015-2016 The Decred developers 3 | // Copyright (C) 2015-2024 The Lightning Network Developers 4 | 5 | package main 6 | 7 | import "github.com/lightningnetwork/lnd/cmd/commands" 8 | 9 | func main() { 10 | commands.Main() 11 | } 12 | -------------------------------------------------------------------------------- /contractcourt/mock_htlcnotifier_test.go: -------------------------------------------------------------------------------- 1 | package contractcourt 2 | 3 | import ( 4 | "github.com/lightningnetwork/lnd/channeldb" 5 | "github.com/lightningnetwork/lnd/graph/db/models" 6 | ) 7 | 8 | type mockHTLCNotifier struct { 9 | HtlcNotifier 10 | } 11 | 12 | func (m *mockHTLCNotifier) NotifyFinalHtlcEvent(key models.CircuitKey, 13 | info channeldb.FinalHtlcInfo) { 14 | 15 | } 16 | -------------------------------------------------------------------------------- /contractcourt/setup_test.go: -------------------------------------------------------------------------------- 1 | package contractcourt 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/lightningnetwork/lnd/kvdb" 7 | ) 8 | 9 | func TestMain(m *testing.M) { 10 | kvdb.RunTests(m) 11 | } 12 | -------------------------------------------------------------------------------- /contrib/init/README.md: -------------------------------------------------------------------------------- 1 | # Init 2 | 3 | Sample configuration files for: 4 | 5 | ``` 6 | systemd: lnd.service 7 | ``` 8 | 9 | ## systemd 10 | 11 | Add the example `lnd.service` file to `/etc/systemd/system/` and modify it according to your system and user configuration. Use the following commands to interact with the service: 12 | 13 | ```bash 14 | # Enable lnd to automatically start on system boot 15 | systemctl enable lnd 16 | 17 | # Start lnd 18 | systemctl start lnd 19 | 20 | # Restart lnd 21 | systemctl restart lnd 22 | 23 | # Stop lnd 24 | systemctl stop lnd 25 | ``` 26 | 27 | Systemd will attempt to restart lnd automatically if it crashes or otherwise stops unexpectedly. 28 | -------------------------------------------------------------------------------- /discovery/log.go: -------------------------------------------------------------------------------- 1 | package discovery 2 | 3 | import ( 4 | "github.com/btcsuite/btclog/v2" 5 | "github.com/lightningnetwork/lnd/build" 6 | ) 7 | 8 | // log is a logger that is initialized with no output filters. This 9 | // means the package will not perform any logging by default until the caller 10 | // requests it. 11 | var log btclog.Logger 12 | 13 | // The default amount of logging is none. 14 | func init() { 15 | UseLogger(build.NewSubLogger("DISC", nil)) 16 | } 17 | 18 | // DisableLog disables all library log output. Logging output is disabled 19 | // by default until UseLogger is called. 20 | func DisableLog() { 21 | UseLogger(btclog.Disabled) 22 | } 23 | 24 | // UseLogger uses a specified Logger to output package logging info. 25 | // This should be used in preference to SetLogWriter if the caller is also 26 | // using btclog. 27 | func UseLogger(logger btclog.Logger) { 28 | log = logger 29 | } 30 | -------------------------------------------------------------------------------- /doc.go: -------------------------------------------------------------------------------- 1 | package lnd 2 | -------------------------------------------------------------------------------- /docker/bitcoind/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM lightninglabs/bitcoin-core:${BITCOIN_VERSION:-25} 2 | 3 | # Copy the start script into the container 4 | COPY start-bitcoind.sh . 5 | 6 | # Set execute permissions for the script 7 | RUN chmod +x ./start-bitcoind.sh 8 | -------------------------------------------------------------------------------- /docs/alloy-models/linear-fee-function/counter-example-show.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lightningnetwork/lnd/5a036a8fcd1ee2ffd8e58290782be68399dcca86/docs/alloy-models/linear-fee-function/counter-example-show.png -------------------------------------------------------------------------------- /docs/alloy-models/linear-fee-function/counter-example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lightningnetwork/lnd/5a036a8fcd1ee2ffd8e58290782be68399dcca86/docs/alloy-models/linear-fee-function/counter-example.png -------------------------------------------------------------------------------- /docs/alloy-models/linear-fee-function/fixed-model.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lightningnetwork/lnd/5a036a8fcd1ee2ffd8e58290782be68399dcca86/docs/alloy-models/linear-fee-function/fixed-model.png -------------------------------------------------------------------------------- /docs/release-notes/release-notes-0.13.2.md: -------------------------------------------------------------------------------- 1 | # Release Notes 2 | 3 | ## AMP 4 | 5 | A new command line option (`--amp-reuse`) has been added to make it easier for 6 | users to re-use AMP invoice on the command line using either the `payinvoice` 7 | or `sendpayment` command. 8 | 9 | ## Bug Fixes 10 | 11 | [A bug has been fixed in the command line argument parsing for the 12 | `sendpayment` command that previously prevented users from being able to re-use 13 | a fully 14 | specified AMP](https://github.com/lightningnetwork/lnd/pull/5554) invoice by 15 | generating a new `pay_addr` and including it as a CLI arg. 16 | 17 | # Contributors (Alphabetical Order) 18 | * Olaoluwa Osuntokun 19 | -------------------------------------------------------------------------------- /docs/release-notes/release-notes-0.13.3.md: -------------------------------------------------------------------------------- 1 | # Release Notes 2 | 3 | ## Wallet 4 | 5 | * [The `DefaultDustLimit` method has been removed in favor of `DustLimitForSize` which calculates the proper network dust limit for a given output size. This also fixes certain APIs like SendCoins to be able to send 294 sats to a P2WPKH script.](https://github.com/lightningnetwork/lnd/pull/5781) 6 | 7 | ## Safety 8 | 9 | * [The `htlcswitch.Switch` has been modified to take into account the total dust sum on the incoming and outgoing channels before forwarding. After the defined threshold is reached, dust HTLC's will start to be failed. The default threshold is 500K satoshis and can be modified by setting `--dust-threshold=` when running `lnd`.](https://github.com/lightningnetwork/lnd/pull/5770) 10 | 11 | # Contributors (Alphabetical Order) 12 | 13 | * Eugene Siegel -------------------------------------------------------------------------------- /docs/release-notes/release-notes-0.14.3.md: -------------------------------------------------------------------------------- 1 | # Release Notes 2 | 3 | ## Bug fixes 4 | 5 | * The REST proxy (`grpc-gateway` library) had a fallback that redirected `POST` 6 | requests to another endpoint _with the same URI_ if no endpoint for `POST` was 7 | registered. [This default behavior was turned 8 | off](https://github.com/lightningnetwork/lnd/pull/6359), enabling strict 9 | HTTP method matching. 10 | 11 | * The [`SignOutputRaw` RPC now works properly in remote signing 12 | mode](https://github.com/lightningnetwork/lnd/pull/6341), even when 13 | only a public key or only a key locator is specified. This allows a Loop or 14 | Pool node to be connected to a remote signing node pair. 15 | A bug in the remote signer health check was also fixed that lead to too many 16 | open connections. 17 | 18 | # Contributors (Alphabetical Order) 19 | 20 | * Oliver Gugger 21 | -------------------------------------------------------------------------------- /docs/release-notes/release-notes-0.15.2.md: -------------------------------------------------------------------------------- 1 | # Release Notes 2 | 3 | ## Bug Fixes 4 | 5 | * [A wire parsing bug has been fixed that would cause lnd to be unable _decode_ 6 | certain large blocks](https://github.com/lightningnetwork/lnd/pull/7004) 7 | 8 | # Contributors (Alphabetical Order) 9 | 10 | * Olaoluwa Osuntokun 11 | -------------------------------------------------------------------------------- /docs/release-notes/release-notes-0.15.4.md: -------------------------------------------------------------------------------- 1 | # Release Notes 2 | 3 | ## Bug Fixes 4 | 5 | * [A wire parsing bug has been fixed that would cause lnd to be unable _decode_ 6 | certain large transactions](https://github.com/lightningnetwork/lnd/pull/7098). 7 | 8 | # Contributors (Alphabetical Order) 9 | 10 | * Oliver Gugger 11 | -------------------------------------------------------------------------------- /docs/release-notes/release-notes-0.15.5.md: -------------------------------------------------------------------------------- 1 | # Release Notes 2 | 3 | ## Bug Fixes 4 | 5 | * [A Taproot related key tweak issue was fixed in `btcd` that affected remote 6 | signing setups](https://github.com/lightningnetwork/lnd/pull/7130). 7 | 8 | * [Taproot changes addresses are now used by default for the `SendCoins` 9 | RPC](https://github.com/lightningnetwork/lnd/pull/7193). 10 | 11 | * [A 1 second interval has been added between `FundingLocked` receipt 12 | checks](https://github.com/lightningnetwork/lnd/pull/7095). This reduces idle 13 | CPU usage for pending/dangling funding attempts. 14 | 15 | # Contributors (Alphabetical Order) 16 | 17 | * Olaoluwa Osuntokun 18 | * Oliver Gugger 19 | * Yong Yu 20 | -------------------------------------------------------------------------------- /docs/release-notes/release-notes-0.16.2.md: -------------------------------------------------------------------------------- 1 | # Release Notes 2 | 3 | ## Wallet 4 | 5 | [The mempool scanning logic no longer blocks start 6 | up](https://github.com/lightningnetwork/lnd/pull/7641). The default polling 7 | interval has also been increased to 60 seconds. 8 | 9 | ## Bug Fixes 10 | 11 | [A panic has been fixed](https://github.com/lightningnetwork/lnd/pull/7637) for 12 | neutrino nodes related to sweeper transaction replacement. 13 | -------------------------------------------------------------------------------- /docs/ruby-thing.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | File.open("INSTALL.md", 'r') do |f| 4 | f.each_line do |line| 5 | forbidden_words = ['Table of contents', 'define', 'pragma'] 6 | next if !line.start_with?("#") || forbidden_words.any? { |w| line =~ /#{w}/ } 7 | 8 | title = line.gsub("#", "").strip 9 | href = title.gsub(" ", "-").downcase 10 | puts " " * (line.count("#")-1) + "* [#{title}](\##{href})" 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /fn/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/lightningnetwork/lnd/fn/v2 2 | 3 | go 1.19 4 | 5 | require ( 6 | github.com/stretchr/testify v1.8.1 7 | golang.org/x/exp v0.0.0-20231226003508-02704c960a9b 8 | golang.org/x/sync v0.7.0 9 | ) 10 | 11 | require ( 12 | github.com/davecgh/go-spew v1.1.1 // indirect 13 | github.com/pmezard/go-difflib v1.0.0 // indirect 14 | gopkg.in/yaml.v3 v3.0.1 // indirect 15 | ) 16 | -------------------------------------------------------------------------------- /fn/predicate.go: -------------------------------------------------------------------------------- 1 | package fn 2 | 3 | // Pred[A] is a type alias for a predicate operating over type A. 4 | type Pred[A any] func(A) bool 5 | 6 | // PredAnd is a lifted version of the && operation that operates over functions 7 | // producing a boolean value from some type A. 8 | func PredAnd[A any](p0 Pred[A], p1 Pred[A]) Pred[A] { 9 | return func(a A) bool { 10 | return p0(a) && p1(a) 11 | } 12 | } 13 | 14 | // PredOr is a lifted version of the || operation that operates over functions 15 | // producing a boolean value from some type A. 16 | func PredOr[A any](p0 Pred[A], p1 Pred[A]) Pred[A] { 17 | return func(a A) bool { 18 | return p0(a) || p1(a) 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /fn/send.go: -------------------------------------------------------------------------------- 1 | package fn 2 | 3 | // SendOrQuit attempts to and a message through channel c. If this succeeds, 4 | // then bool is returned. Otherwise if a quit signal is received first, then 5 | // false is returned. 6 | func SendOrQuit[T any, Q any](c chan<- T, msg T, quit chan Q) bool { 7 | select { 8 | case c <- msg: 9 | return true 10 | case <-quit: 11 | return false 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /funding/config_integration.go: -------------------------------------------------------------------------------- 1 | //go:build integration 2 | 3 | package funding 4 | 5 | import "time" 6 | 7 | func init() { 8 | // For itest, we will use a much shorter checking interval here as 9 | // local communications are very fast. 10 | checkPeerChannelReadyInterval = 10 * time.Millisecond 11 | } 12 | -------------------------------------------------------------------------------- /funding/log.go: -------------------------------------------------------------------------------- 1 | package funding 2 | 3 | import ( 4 | "github.com/btcsuite/btclog/v2" 5 | "github.com/lightningnetwork/lnd/build" 6 | ) 7 | 8 | // Subsystem defines the logging code for this subsystem. 9 | const Subsystem = "FNDG" 10 | 11 | // log is a logger that is initialized with the btclog.Disabled logger. 12 | var log btclog.Logger 13 | 14 | // The default amount of logging is none. 15 | func init() { 16 | UseLogger(build.NewSubLogger(Subsystem, nil)) 17 | } 18 | 19 | // DisableLog disables all logging output. 20 | func DisableLog() { 21 | UseLogger(btclog.Disabled) 22 | } 23 | 24 | // UseLogger uses a specified Logger to output package logging info. 25 | func UseLogger(logger btclog.Logger) { 26 | log = logger 27 | } 28 | -------------------------------------------------------------------------------- /graph/db/log.go: -------------------------------------------------------------------------------- 1 | package graphdb 2 | 3 | import ( 4 | "github.com/btcsuite/btclog" 5 | "github.com/lightningnetwork/lnd/build" 6 | ) 7 | 8 | // Subsystem defines the logging code for this subsystem. 9 | const Subsystem = "GRDB" 10 | 11 | // log is a logger that is initialized with no output filters. This 12 | // means the package will not perform any logging by default until the caller 13 | // requests it. 14 | var log btclog.Logger 15 | 16 | func init() { 17 | UseLogger(build.NewSubLogger(Subsystem, nil)) 18 | } 19 | 20 | // DisableLog disables all library log output. Logging output is disabled 21 | // by default until UseLogger is called. 22 | func DisableLog() { 23 | UseLogger(btclog.Disabled) 24 | } 25 | 26 | // UseLogger uses a specified Logger to output package logging info. 27 | // This should be used in preference to SetLogWriter if the caller is also 28 | // using btclog. 29 | func UseLogger(logger btclog.Logger) { 30 | log = logger 31 | } 32 | -------------------------------------------------------------------------------- /graph/db/models/inbound_fee_test.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/stretchr/testify/require" 7 | ) 8 | 9 | func TestInboundFee(t *testing.T) { 10 | t.Parallel() 11 | 12 | // Test positive fee. 13 | i := InboundFee{ 14 | Base: 5, 15 | Rate: 500000, 16 | } 17 | 18 | require.Equal(t, int64(6), i.CalcFee(2)) 19 | 20 | // Expect fee to be rounded down. 21 | require.Equal(t, int64(6), i.CalcFee(3)) 22 | 23 | // Test negative fee. 24 | i = InboundFee{ 25 | Base: -5, 26 | Rate: -500000, 27 | } 28 | 29 | require.Equal(t, int64(-6), i.CalcFee(2)) 30 | 31 | // Expect fee to be rounded up. 32 | require.Equal(t, int64(-6), i.CalcFee(3)) 33 | } 34 | -------------------------------------------------------------------------------- /graph/db/setup_test.go: -------------------------------------------------------------------------------- 1 | package graphdb 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/lightningnetwork/lnd/kvdb" 7 | ) 8 | 9 | func TestMain(m *testing.M) { 10 | kvdb.RunTests(m) 11 | } 12 | -------------------------------------------------------------------------------- /graph/db/test_kvdb.go: -------------------------------------------------------------------------------- 1 | //go:build !test_db_sqlite && !test_db_postgres 2 | 3 | package graphdb 4 | 5 | import ( 6 | "testing" 7 | 8 | "github.com/lightningnetwork/lnd/kvdb" 9 | "github.com/stretchr/testify/require" 10 | ) 11 | 12 | // NewTestDB is a helper function that creates an BBolt database for testing. 13 | func NewTestDB(t testing.TB) V1Store { 14 | backend, backendCleanup, err := kvdb.GetTestBackend(t.TempDir(), "cgr") 15 | require.NoError(t, err) 16 | 17 | t.Cleanup(backendCleanup) 18 | 19 | graphStore, err := NewKVStore(backend) 20 | require.NoError(t, err) 21 | 22 | return graphStore 23 | } 24 | -------------------------------------------------------------------------------- /graph/log.go: -------------------------------------------------------------------------------- 1 | package graph 2 | 3 | import ( 4 | "github.com/btcsuite/btclog/v2" 5 | "github.com/lightningnetwork/lnd/build" 6 | ) 7 | 8 | // log is a logger that is initialized with no output filters. This means the 9 | // package will not perform any logging by default until the caller requests 10 | // it. 11 | var log btclog.Logger 12 | 13 | const Subsystem = "GRPH" 14 | 15 | // The default amount of logging is none. 16 | func init() { 17 | UseLogger(build.NewSubLogger(Subsystem, nil)) 18 | } 19 | 20 | // DisableLog disables all library log output. Logging output is disabled by 21 | // default until UseLogger is called. 22 | func DisableLog() { 23 | UseLogger(btclog.Disabled) 24 | } 25 | 26 | // UseLogger uses a specified Logger to output package logging info. This 27 | // should be used in preference to SetLogWriter if the caller is also using 28 | // btclog. 29 | func UseLogger(logger btclog.Logger) { 30 | log = logger 31 | } 32 | -------------------------------------------------------------------------------- /graph/setup_test.go: -------------------------------------------------------------------------------- 1 | package graph 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/lightningnetwork/lnd/kvdb" 7 | ) 8 | 9 | func TestMain(m *testing.M) { 10 | kvdb.RunTests(m) 11 | } 12 | -------------------------------------------------------------------------------- /healthcheck/diskcheck_js.go: -------------------------------------------------------------------------------- 1 | package healthcheck 2 | 3 | import "fmt" 4 | 5 | // AvailableDiskSpaceRatio returns ratio of available disk space to total 6 | // capacity. 7 | func AvailableDiskSpaceRatio(_ string) (float64, error) { 8 | return 0, fmt.Errorf("disk space check not supported in WebAssembly") 9 | } 10 | 11 | // AvailableDiskSpace returns the available disk space in bytes of the given 12 | // file system. 13 | func AvailableDiskSpace(_ string) (uint64, error) { 14 | return 0, fmt.Errorf("disk space check not supported in WebAssembly") 15 | } 16 | -------------------------------------------------------------------------------- /healthcheck/diskcheck_netbsd.go: -------------------------------------------------------------------------------- 1 | package healthcheck 2 | 3 | import "golang.org/x/sys/unix" 4 | 5 | // AvailableDiskSpaceRatio returns ratio of available disk space to total 6 | // capacity for netbsd. 7 | func AvailableDiskSpaceRatio(path string) (float64, error) { 8 | s := unix.Statvfs_t{} 9 | err := unix.Statvfs(path, &s) 10 | if err != nil { 11 | return 0, err 12 | } 13 | 14 | // Calculate our free blocks/total blocks to get our total ratio of 15 | // free blocks. 16 | return float64(s.Bfree) / float64(s.Blocks), nil 17 | } 18 | 19 | // AvailableDiskSpace returns the available disk space in bytes of the given 20 | // file system for netbsd. 21 | func AvailableDiskSpace(path string) (uint64, error) { 22 | s := unix.Statvfs_t{} 23 | err := unix.Statvfs(path, &s) 24 | if err != nil { 25 | return 0, err 26 | } 27 | 28 | return s.Bavail * uint64(s.Bsize), nil 29 | } 30 | -------------------------------------------------------------------------------- /healthcheck/diskcheck_openbsd.go: -------------------------------------------------------------------------------- 1 | package healthcheck 2 | 3 | import "golang.org/x/sys/unix" 4 | 5 | // AvailableDiskSpaceRatio returns ratio of available disk space to total 6 | // capacity for openbsd. 7 | func AvailableDiskSpaceRatio(path string) (float64, error) { 8 | s := unix.Statfs_t{} 9 | err := unix.Statfs(path, &s) 10 | if err != nil { 11 | return 0, err 12 | } 13 | 14 | // Calculate our free blocks/total blocks to get our total ratio of 15 | // free blocks. 16 | return float64(s.F_bfree) / float64(s.F_blocks), nil 17 | } 18 | 19 | // AvailableDiskSpace returns the available disk space in bytes of the given 20 | // file system for openbsd. 21 | func AvailableDiskSpace(path string) (uint64, error) { 22 | s := unix.Statfs_t{} 23 | err := unix.Statfs(path, &s) 24 | if err != nil { 25 | return 0, err 26 | } 27 | 28 | return uint64(s.F_bavail) * uint64(s.F_bsize), nil 29 | } 30 | -------------------------------------------------------------------------------- /healthcheck/diskcheck_solaris.go: -------------------------------------------------------------------------------- 1 | package healthcheck 2 | 3 | import "golang.org/x/sys/unix" 4 | 5 | // AvailableDiskSpaceRatio returns ratio of available disk space to total 6 | // capacity for solaris. 7 | func AvailableDiskSpaceRatio(path string) (float64, error) { 8 | s := unix.Statvfs_t{} 9 | err := unix.Statvfs(path, &s) 10 | if err != nil { 11 | return 0, err 12 | } 13 | 14 | // Calculate our free blocks/total blocks to get our total ratio of 15 | // free blocks. 16 | return float64(s.Bfree) / float64(s.Blocks), nil 17 | } 18 | 19 | // AvailableDiskSpace returns the available disk space in bytes of the given 20 | // file system for solaris. 21 | func AvailableDiskSpace(path string) (uint64, error) { 22 | s := unix.Statvfs_t{} 23 | err := unix.Statvfs(path, &s) 24 | if err != nil { 25 | return 0, err 26 | } 27 | 28 | return s.Bavail * uint64(s.Bsize), nil 29 | } 30 | -------------------------------------------------------------------------------- /healthcheck/diskcheck_windows.go: -------------------------------------------------------------------------------- 1 | package healthcheck 2 | 3 | import "golang.org/x/sys/windows" 4 | 5 | // AvailableDiskSpaceRatio returns ratio of available disk space to total 6 | // capacity for windows. 7 | func AvailableDiskSpaceRatio(path string) (float64, error) { 8 | var free, total, avail uint64 9 | 10 | pathPtr, err := windows.UTF16PtrFromString(path) 11 | if err != nil { 12 | return 0, err 13 | } 14 | err = windows.GetDiskFreeSpaceEx(pathPtr, &free, &total, &avail) 15 | 16 | return float64(avail) / float64(total), nil 17 | } 18 | 19 | // AvailableDiskSpace returns the available disk space in bytes of the given 20 | // file system for windows. 21 | func AvailableDiskSpace(path string) (uint64, error) { 22 | var free, total, avail uint64 23 | 24 | pathPtr, err := windows.UTF16PtrFromString(path) 25 | if err != nil { 26 | return 0, err 27 | } 28 | err = windows.GetDiskFreeSpaceEx(pathPtr, &free, &total, &avail) 29 | 30 | return avail, nil 31 | } 32 | -------------------------------------------------------------------------------- /healthcheck/log.go: -------------------------------------------------------------------------------- 1 | package healthcheck 2 | 3 | import "github.com/btcsuite/btclog/v2" 4 | 5 | // Subsystem defines the logging code for this subsystem. 6 | const Subsystem = "HLCK" 7 | 8 | // log is a logger that is initialized with no output filters. This 9 | // means the package will not perform any logging by default until the caller 10 | // requests it. 11 | var log = btclog.Disabled 12 | 13 | // DisableLog disables all library log output. Logging output is disabled 14 | // by default until UseLogger is called. 15 | func DisableLog() { 16 | UseLogger(btclog.Disabled) 17 | } 18 | 19 | // UseLogger uses a specified Logger to output package logging info. 20 | // This should be used in preference to SetLogWriter if the caller is also 21 | // using btclog. 22 | func UseLogger(logger btclog.Logger) { 23 | log = logger 24 | } 25 | -------------------------------------------------------------------------------- /htlcswitch/hodl/config_prod.go: -------------------------------------------------------------------------------- 1 | //go:build !dev 2 | // +build !dev 3 | 4 | package hodl 5 | 6 | // Config is an empty struct disabling command line hodl flags in production. 7 | type Config struct{} 8 | 9 | // Mask in production always returns MaskNone. 10 | func (c *Config) Mask() Mask { 11 | return MaskNone 12 | } 13 | -------------------------------------------------------------------------------- /htlcswitch/hodl/mask_dev.go: -------------------------------------------------------------------------------- 1 | //go:build dev 2 | // +build dev 3 | 4 | package hodl 5 | 6 | import ( 7 | "fmt" 8 | "strings" 9 | ) 10 | 11 | // MaskFromFlags merges a variadic set of Flags into a single Mask. 12 | func MaskFromFlags(flags ...Flag) Mask { 13 | var mask Mask 14 | for _, flag := range flags { 15 | mask |= Mask(flag) 16 | } 17 | 18 | return mask 19 | } 20 | 21 | // Active returns true if the bit corresponding to the flag is set within the 22 | // mask. 23 | func (m Mask) Active(flag Flag) bool { 24 | return (Flag(m) & flag) > 0 25 | } 26 | 27 | // String returns a human-readable description of all active Flags. 28 | func (m Mask) String() string { 29 | if m == MaskNone { 30 | return "hodl.Mask(NONE)" 31 | } 32 | 33 | var activeFlags []string 34 | for i := uint(0); i < 32; i++ { 35 | flag := Flag(1 << i) 36 | if m.Active(flag) { 37 | activeFlags = append(activeFlags, flag.String()) 38 | } 39 | } 40 | 41 | return fmt.Sprintf("hodl.Mask(%s)", strings.Join(activeFlags, "|")) 42 | } 43 | -------------------------------------------------------------------------------- /htlcswitch/hodl/mask_prod.go: -------------------------------------------------------------------------------- 1 | //go:build !dev 2 | // +build !dev 3 | 4 | package hodl 5 | 6 | // MaskFromFlags in production always returns MaskNone. 7 | func MaskFromFlags(_ ...Flag) Mask { 8 | return MaskNone 9 | } 10 | 11 | // Active in production always returns false for all Flags. 12 | func (m Mask) Active(_ Flag) bool { 13 | return false 14 | } 15 | 16 | // String returns the human-readable identifier for MaskNone. 17 | func (m Mask) String() string { 18 | return "hodl.Mask(NONE)" 19 | } 20 | -------------------------------------------------------------------------------- /htlcswitch/hop/log.go: -------------------------------------------------------------------------------- 1 | package hop 2 | 3 | import ( 4 | "github.com/btcsuite/btclog/v2" 5 | ) 6 | 7 | // log is a logger that is initialized with no output filters. This 8 | // means the package will not perform any logging by default until the caller 9 | // requests it. 10 | var log btclog.Logger 11 | 12 | // UseLogger uses a specified Logger to output package logging info. This 13 | // function is called from the parent package htlcswitch logger initialization. 14 | func UseLogger(logger btclog.Logger) { 15 | log = logger 16 | } 17 | -------------------------------------------------------------------------------- /htlcswitch/hop/type.go: -------------------------------------------------------------------------------- 1 | package hop 2 | 3 | import "github.com/lightningnetwork/lnd/lnwire" 4 | 5 | var ( 6 | // Exit is a special "hop" denoting that an incoming HTLC is meant to 7 | // pay finally to the receiving node. 8 | Exit lnwire.ShortChannelID 9 | 10 | // Source is a sentinel "hop" denoting that an incoming HTLC is 11 | // initiated by our own switch. 12 | Source lnwire.ShortChannelID 13 | ) 14 | -------------------------------------------------------------------------------- /htlcswitch/log.go: -------------------------------------------------------------------------------- 1 | package htlcswitch 2 | 3 | import ( 4 | "github.com/btcsuite/btclog/v2" 5 | "github.com/lightningnetwork/lnd/build" 6 | "github.com/lightningnetwork/lnd/htlcswitch/hop" 7 | ) 8 | 9 | // log is a logger that is initialized with no output filters. This 10 | // means the package will not perform any logging by default until the caller 11 | // requests it. 12 | var log btclog.Logger 13 | 14 | // The default amount of logging is none. 15 | func init() { 16 | logger := build.NewSubLogger("HSWC", nil) 17 | 18 | UseLogger(logger) 19 | } 20 | 21 | // DisableLog disables all library log output. Logging output is disabled 22 | // by default until UseLogger is called. 23 | func DisableLog() { 24 | UseLogger(btclog.Disabled) 25 | } 26 | 27 | // UseLogger uses a specified Logger to output package logging info. 28 | // This should be used in preference to SetLogWriter if the caller is also 29 | // using btclog. 30 | func UseLogger(logger btclog.Logger) { 31 | log = logger 32 | hop.UseLogger(logger) 33 | } 34 | -------------------------------------------------------------------------------- /internal/musig2v040/README.md: -------------------------------------------------------------------------------- 1 | # MuSig2 v0.4.0 2 | 3 | This package contains an exact copy of the MuSig2 code as found in 4 | `github.com/btcsuite/btcec/v2/schnorr/musig2` at the tag `btcec/v2.2.2`. 5 | 6 | This corresponds to the [MuSig2 BIP specification version of 7 | `v0.4.0`](https://github.com/jonasnick/bips/blob/musig2/bip-musig2.mediawiki). 8 | 9 | We only keep this code here to allow implementing a backward compatible, 10 | versioned MuSig2 RPC. 11 | -------------------------------------------------------------------------------- /invoices/log.go: -------------------------------------------------------------------------------- 1 | package invoices 2 | 3 | import ( 4 | "github.com/btcsuite/btclog/v2" 5 | "github.com/lightningnetwork/lnd/build" 6 | ) 7 | 8 | // log is a logger that is initialized with no output filters. This 9 | // means the package will not perform any logging by default until the caller 10 | // requests it. 11 | var log btclog.Logger 12 | 13 | // The default amount of logging is none. 14 | func init() { 15 | UseLogger(build.NewSubLogger("INVC", nil)) 16 | } 17 | 18 | // DisableLog disables all library log output. Logging output is disabled 19 | // by default until UseLogger is called. 20 | func DisableLog() { 21 | UseLogger(btclog.Disabled) 22 | } 23 | 24 | // UseLogger uses a specified Logger to output package logging info. 25 | // This should be used in preference to SetLogWriter if the caller is also 26 | // using btclog. 27 | func UseLogger(logger btclog.Logger) { 28 | log = logger 29 | } 30 | -------------------------------------------------------------------------------- /invoices/setup_test.go: -------------------------------------------------------------------------------- 1 | package invoices 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/lightningnetwork/lnd/kvdb" 7 | ) 8 | 9 | func TestMain(m *testing.M) { 10 | kvdb.RunTests(m) 11 | } 12 | -------------------------------------------------------------------------------- /invoices/testdata/channel.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lightningnetwork/lnd/5a036a8fcd1ee2ffd8e58290782be68399dcca86/invoices/testdata/channel.db -------------------------------------------------------------------------------- /itest/list_off_test.go: -------------------------------------------------------------------------------- 1 | //go:build !integration 2 | 3 | package itest 4 | 5 | import "github.com/lightningnetwork/lnd/lntest" 6 | 7 | var allTestCases = []*lntest.TestCase{} 8 | -------------------------------------------------------------------------------- /itest/lnd_no_etcd_dummy_failover_test.go: -------------------------------------------------------------------------------- 1 | //go:build !kvdb_etcd 2 | // +build !kvdb_etcd 3 | 4 | package itest 5 | 6 | import "github.com/lightningnetwork/lnd/lntest" 7 | 8 | // testEtcdFailover is an empty itest when LND is not compiled with etcd 9 | // support. 10 | func testEtcdFailover(ht *lntest.HarnessTest) {} 11 | 12 | // testLeaderHealthCheck is an empty itest when LND is not compiled with etcd 13 | // support. 14 | func testLeaderHealthCheck(ht *lntest.HarnessTest) {} 15 | -------------------------------------------------------------------------------- /itest/log_check_errors.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | BASEDIR=$(dirname "$0") 4 | 5 | echo "" 6 | 7 | # Filter all log files for errors, substitute variable data and match against whitelist. 8 | find $BASEDIR -name "*.log" | xargs grep -h "\[ERR\]" | \ 9 | sed -r -f $BASEDIR/log_substitutions.txt | \ 10 | sort | uniq | \ 11 | grep -Fvi -f $BASEDIR/log_error_whitelist.txt 12 | 13 | # If something shows up (not on whitelist) exit with error code 1. 14 | if [[ $? -eq 0 ]]; then 15 | echo "" 16 | echo "In the itest logs, the log line (patterns) above were detected." 17 | echo "[ERR] lines are generally reserved for internal errors." 18 | echo "Resolve the issue by either changing the log level or adding an " 19 | echo "exception to log_error_whitelist.txt" 20 | echo "" 21 | 22 | exit 1 23 | fi 24 | 25 | echo "No itest errors detected." 26 | echo "" 27 | -------------------------------------------------------------------------------- /keychain/bench_test.go: -------------------------------------------------------------------------------- 1 | package keychain 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/btcsuite/btcd/btcec/v2" 7 | "github.com/stretchr/testify/require" 8 | ) 9 | 10 | func BenchmarkDerivePrivKey(t *testing.B) { 11 | wallet, err := createTestBtcWallet(t, CoinTypeBitcoin) 12 | require.NoError(t, err, "unable to create wallet") 13 | 14 | keyRing := NewBtcWalletKeyRing(wallet, CoinTypeBitcoin) 15 | 16 | var ( 17 | privKey *btcec.PrivateKey 18 | ) 19 | 20 | keyDesc := KeyDescriptor{ 21 | KeyLocator: KeyLocator{ 22 | Family: KeyFamilyMultiSig, 23 | Index: 1, 24 | }, 25 | } 26 | 27 | t.ReportAllocs() 28 | t.ResetTimer() 29 | 30 | for i := 0; i < t.N; i++ { 31 | privKey, err = keyRing.DerivePrivKey(keyDesc) 32 | } 33 | require.NoError(t, err) 34 | require.NotNil(t, privKey) 35 | } 36 | -------------------------------------------------------------------------------- /kvdb/bolt_fixture.go: -------------------------------------------------------------------------------- 1 | package kvdb 2 | 3 | import ( 4 | "path/filepath" 5 | "testing" 6 | 7 | "github.com/btcsuite/btcwallet/walletdb" 8 | "github.com/stretchr/testify/require" 9 | ) 10 | 11 | type boltFixture struct { 12 | t *testing.T 13 | tempDir string 14 | } 15 | 16 | func NewBoltFixture(t *testing.T) *boltFixture { 17 | return &boltFixture{ 18 | t: t, 19 | tempDir: t.TempDir(), 20 | } 21 | } 22 | 23 | func (b *boltFixture) NewBackend() walletdb.DB { 24 | dbPath := filepath.Join(b.tempDir) 25 | 26 | db, err := GetBoltBackend(&BoltBackendConfig{ 27 | DBPath: dbPath, 28 | DBFileName: "test.db", 29 | NoFreelistSync: true, 30 | DBTimeout: DefaultDBTimeout, 31 | ReadOnly: false, 32 | }) 33 | require.NoError(b.t, err) 34 | 35 | return db 36 | } 37 | -------------------------------------------------------------------------------- /kvdb/debug.go: -------------------------------------------------------------------------------- 1 | //go:build dev 2 | // +build dev 3 | 4 | package kvdb 5 | 6 | const ( 7 | // Switch on extra debug code. 8 | etcdDebug = true 9 | ) 10 | -------------------------------------------------------------------------------- /kvdb/etcd/debug.go: -------------------------------------------------------------------------------- 1 | //go:build dev 2 | // +build dev 3 | 4 | package etcd 5 | 6 | const ( 7 | // Switch on extra debug code. 8 | etcdDebug = true 9 | ) 10 | -------------------------------------------------------------------------------- /kvdb/etcd/driver_test.go: -------------------------------------------------------------------------------- 1 | //go:build kvdb_etcd 2 | // +build kvdb_etcd 3 | 4 | package etcd 5 | 6 | import ( 7 | "testing" 8 | 9 | "github.com/btcsuite/btcwallet/walletdb" 10 | "github.com/stretchr/testify/require" 11 | ) 12 | 13 | func TestOpenCreateFailure(t *testing.T) { 14 | t.Parallel() 15 | 16 | db, err := walletdb.Open(dbType) 17 | require.Error(t, err) 18 | require.Nil(t, db) 19 | 20 | db, err = walletdb.Open(dbType, "wrong") 21 | require.Error(t, err) 22 | require.Nil(t, db) 23 | 24 | db, err = walletdb.Create(dbType) 25 | require.Error(t, err) 26 | require.Nil(t, db) 27 | 28 | db, err = walletdb.Create(dbType, "wrong") 29 | require.Error(t, err) 30 | require.Nil(t, db) 31 | } 32 | -------------------------------------------------------------------------------- /kvdb/etcd/nodebug.go: -------------------------------------------------------------------------------- 1 | //go:build !dev 2 | // +build !dev 3 | 4 | package etcd 5 | 6 | const ( 7 | // Switch off extra debug code. 8 | etcdDebug = false 9 | ) 10 | -------------------------------------------------------------------------------- /kvdb/etcd/walletdb_interface_test.go: -------------------------------------------------------------------------------- 1 | //go:build kvdb_etcd 2 | // +build kvdb_etcd 3 | 4 | package etcd 5 | 6 | import ( 7 | "context" 8 | "testing" 9 | 10 | "github.com/btcsuite/btcwallet/walletdb/walletdbtest" 11 | ) 12 | 13 | // TestWalletDBInterface performs the WalletDB interface test suite for the 14 | // etcd database driver. 15 | func TestWalletDBInterface(t *testing.T) { 16 | f := NewEtcdTestFixture(t) 17 | cfg := f.BackendConfig() 18 | walletdbtest.TestInterface(t, dbType, context.Background(), &cfg) 19 | } 20 | -------------------------------------------------------------------------------- /kvdb/kvdb_etcd.go: -------------------------------------------------------------------------------- 1 | //go:build kvdb_etcd 2 | // +build kvdb_etcd 3 | 4 | package kvdb 5 | 6 | import ( 7 | "github.com/lightningnetwork/lnd/kvdb/etcd" 8 | ) 9 | 10 | // EtcdBackend is conditionally set to etcd when the kvdb_etcd build tag is 11 | // defined, allowing testing our database code with etcd backend. 12 | const EtcdBackend = true 13 | 14 | // GetEtcdTestBackend creates an embedded etcd backend for testing 15 | // storig the database at the passed path. 16 | func StartEtcdTestBackend(path string, clientPort, peerPort uint16, 17 | logFile string) (*etcd.Config, func(), error) { 18 | 19 | return etcd.NewEmbeddedEtcdInstance( 20 | path, clientPort, peerPort, logFile, 21 | ) 22 | } 23 | -------------------------------------------------------------------------------- /kvdb/kvdb_no_etcd.go: -------------------------------------------------------------------------------- 1 | //go:build !kvdb_etcd 2 | // +build !kvdb_etcd 3 | 4 | package kvdb 5 | 6 | import ( 7 | "fmt" 8 | 9 | "github.com/lightningnetwork/lnd/kvdb/etcd" 10 | ) 11 | 12 | // EtcdBackend is conditionally set to false when the kvdb_etcd build tag is not 13 | // defined. This will allow testing of other database backends. 14 | const EtcdBackend = false 15 | 16 | var errEtcdNotAvailable = fmt.Errorf("etcd backend not available") 17 | 18 | // StartEtcdTestBackend is a stub returning nil, and errEtcdNotAvailable error. 19 | func StartEtcdTestBackend(path string, clientPort, peerPort uint16, 20 | logFile string) (*etcd.Config, func(), error) { 21 | 22 | return nil, func() {}, errEtcdNotAvailable 23 | } 24 | -------------------------------------------------------------------------------- /kvdb/kvdb_no_postgres.go: -------------------------------------------------------------------------------- 1 | //go:build !kvdb_postgres 2 | // +build !kvdb_postgres 3 | 4 | package kvdb 5 | 6 | import ( 7 | "errors" 8 | 9 | "github.com/lightningnetwork/lnd/kvdb/postgres" 10 | ) 11 | 12 | const PostgresBackend = false 13 | 14 | func NewPostgresFixture(dbName string) (postgres.Fixture, error) { 15 | return nil, errors.New("postgres backend not available") 16 | } 17 | 18 | func StartEmbeddedPostgres() (func() error, error) { 19 | return nil, errors.New("postgres backend not available") 20 | } 21 | -------------------------------------------------------------------------------- /kvdb/kvdb_no_sqlite.go: -------------------------------------------------------------------------------- 1 | //go:build !kvdb_sqlite || (windows && (arm || 386)) || (linux && (ppc64 || mips || mipsle || mips64)) 2 | 3 | package kvdb 4 | 5 | import ( 6 | "fmt" 7 | "runtime" 8 | 9 | "github.com/btcsuite/btcwallet/walletdb" 10 | ) 11 | 12 | var errSqliteNotAvailable = fmt.Errorf("sqlite backend not available either "+ 13 | "due to the `kvdb_sqlite` build tag not being set, or due to this "+ 14 | "OS(%s) and/or architecture(%s) not being supported", runtime.GOOS, 15 | runtime.GOARCH) 16 | 17 | // SqliteBackend is conditionally set to false when the kvdb_sqlite build tag is 18 | // not defined. This will allow testing of other database backends. 19 | const SqliteBackend = false 20 | 21 | // StartSqliteTestBackend is a stub returning nil, and errSqliteNotAvailable 22 | // error. 23 | func StartSqliteTestBackend(path, name, table string) (walletdb.DB, error) { 24 | return nil, errSqliteNotAvailable 25 | } 26 | -------------------------------------------------------------------------------- /kvdb/kvdb_postgres.go: -------------------------------------------------------------------------------- 1 | //go:build kvdb_postgres 2 | // +build kvdb_postgres 3 | 4 | package kvdb 5 | 6 | import "github.com/lightningnetwork/lnd/kvdb/postgres" 7 | 8 | const PostgresBackend = true 9 | 10 | func NewPostgresFixture(dbName string) (postgres.Fixture, error) { 11 | return postgres.NewFixture(dbName) 12 | } 13 | 14 | func StartEmbeddedPostgres() (func() error, error) { 15 | return postgres.StartEmbeddedPostgres() 16 | } 17 | -------------------------------------------------------------------------------- /kvdb/log.go: -------------------------------------------------------------------------------- 1 | package kvdb 2 | 3 | import ( 4 | "github.com/btcsuite/btclog/v2" 5 | "github.com/lightningnetwork/lnd/kvdb/sqlbase" 6 | ) 7 | 8 | // log is a logger that is initialized as disabled. This means the package will 9 | // not perform any logging by default until a logger is set. 10 | var log = btclog.Disabled 11 | 12 | // UseLogger uses a specified Logger to output package logging info. 13 | func UseLogger(logger btclog.Logger) { 14 | log = logger 15 | 16 | sqlbase.UseLogger(log) 17 | } 18 | -------------------------------------------------------------------------------- /kvdb/nodebug.go: -------------------------------------------------------------------------------- 1 | //go:build !dev 2 | // +build !dev 3 | 4 | package kvdb 5 | 6 | const ( 7 | // Switch off extra debug code. 8 | etcdDebug = false 9 | ) 10 | -------------------------------------------------------------------------------- /kvdb/postgres/config.go: -------------------------------------------------------------------------------- 1 | package postgres 2 | 3 | import "time" 4 | 5 | // Config holds postgres configuration data. 6 | // 7 | //nolint:ll 8 | type Config struct { 9 | Dsn string `long:"dsn" description:"Database connection string."` 10 | Timeout time.Duration `long:"timeout" description:"Database connection timeout. Set to zero to disable."` 11 | MaxConnections int `long:"maxconnections" description:"The maximum number of open connections to the database. Set to zero for unlimited."` 12 | WithGlobalLock bool `long:"withgloballock" description:"Use a global lock to ensure a single writer."` 13 | } 14 | -------------------------------------------------------------------------------- /kvdb/postgres/fixture_interface.go: -------------------------------------------------------------------------------- 1 | package postgres 2 | 3 | import "github.com/btcsuite/btcwallet/walletdb" 4 | 5 | type Fixture interface { 6 | DB() walletdb.DB 7 | Dump() (map[string]interface{}, error) 8 | } 9 | -------------------------------------------------------------------------------- /kvdb/sqlbase/log.go: -------------------------------------------------------------------------------- 1 | package sqlbase 2 | 3 | import "github.com/btcsuite/btclog/v2" 4 | 5 | // log is a logger that is initialized as disabled. This means the package will 6 | // not perform any logging by default until a logger is set. 7 | var log = btclog.Disabled 8 | 9 | // UseLogger uses a specified Logger to output package logging info. 10 | func UseLogger(logger btclog.Logger) { 11 | log = logger 12 | } 13 | -------------------------------------------------------------------------------- /kvdb/sqlbase/no_sql.go: -------------------------------------------------------------------------------- 1 | //go:build !kvdb_postgres && (!kvdb_sqlite || (windows && (arm || 386)) || (linux && (ppc64 || mips || mipsle || mips64))) 2 | 3 | package sqlbase 4 | 5 | func Init(maxConnections int) {} 6 | -------------------------------------------------------------------------------- /kvdb/sqlite/config.go: -------------------------------------------------------------------------------- 1 | package sqlite 2 | 3 | import "time" 4 | 5 | // Config holds sqlite configuration data. 6 | // 7 | //nolint:ll 8 | type Config struct { 9 | Timeout time.Duration `long:"timeout" description:"The time after which a database query should be timed out."` 10 | BusyTimeout time.Duration `long:"busytimeout" description:"The maximum amount of time to wait for a database connection to become available for a query."` 11 | MaxConnections int `long:"maxconnections" description:"The maximum number of open connections to the database. Set to zero for unlimited."` 12 | PragmaOptions []string `long:"pragmaoptions" description:"A list of pragma options to set on a database connection. For example, 'auto_vacuum=incremental'. Note that the flag must be specified multiple times if multiple options are to be set."` 13 | } 14 | -------------------------------------------------------------------------------- /kvdb/sqlite/db_test.go: -------------------------------------------------------------------------------- 1 | //go:build kvdb_sqlite && !(windows && (arm || 386)) && !(linux && (ppc64 || mips || mipsle || mips64)) 2 | 3 | package sqlite 4 | 5 | import ( 6 | "testing" 7 | "time" 8 | 9 | "github.com/btcsuite/btcwallet/walletdb/walletdbtest" 10 | "github.com/lightningnetwork/lnd/kvdb/sqlbase" 11 | "github.com/stretchr/testify/require" 12 | "golang.org/x/net/context" 13 | ) 14 | 15 | // TestInterface performs all interfaces tests for this database driver. 16 | func TestInterface(t *testing.T) { 17 | // dbType is the database type name for this driver. 18 | dir := t.TempDir() 19 | ctx := context.Background() 20 | 21 | sqlbase.Init(0) 22 | 23 | cfg := &Config{ 24 | BusyTimeout: time.Second * 5, 25 | } 26 | 27 | sqlDB, err := NewSqliteBackend(ctx, cfg, dir, "tmp.db", "table") 28 | require.NoError(t, err) 29 | 30 | t.Cleanup(func() { 31 | require.NoError(t, sqlDB.Close()) 32 | }) 33 | 34 | walletdbtest.TestInterface(t, dbType, ctx, cfg, dir, "tmp.db", "temp") 35 | } 36 | -------------------------------------------------------------------------------- /kvdb/test.go: -------------------------------------------------------------------------------- 1 | package kvdb 2 | 3 | type KV struct { 4 | key string 5 | val string 6 | } 7 | 8 | func reverseKVs(a []KV) []KV { 9 | for i, j := 0, len(a)-1; i < j; i, j = i+1, j-1 { 10 | a[i], a[j] = a[j], a[i] 11 | } 12 | 13 | return a 14 | } 15 | -------------------------------------------------------------------------------- /kvdb/test_utils.go: -------------------------------------------------------------------------------- 1 | package kvdb 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | "testing" 7 | ) 8 | 9 | // RunTests is a helper function to run the tests in a package with 10 | // initialization and tear-down of a test kvdb backend. 11 | func RunTests(m *testing.M) { 12 | var close func() error 13 | if PostgresBackend { 14 | var err error 15 | close, err = StartEmbeddedPostgres() 16 | if err != nil { 17 | fmt.Printf("Error: %v\n", err) 18 | os.Exit(1) 19 | } 20 | } 21 | 22 | // os.Exit() does not respect defer statements 23 | code := m.Run() 24 | 25 | if close != nil { 26 | err := close() 27 | if err != nil { 28 | fmt.Printf("Error: %v\n", err) 29 | } 30 | } 31 | 32 | os.Exit(code) 33 | 34 | } 35 | -------------------------------------------------------------------------------- /lncfg/btcd.go: -------------------------------------------------------------------------------- 1 | package lncfg 2 | 3 | // Btcd holds the configuration options for the daemon's connection to btcd. 4 | // 5 | //nolint:ll 6 | type Btcd struct { 7 | Dir string `long:"dir" description:"The base directory that contains the node's data, logs, configuration file, etc."` 8 | RPCHost string `long:"rpchost" description:"The daemon's rpc listening address. If a port is omitted, then the default port for the selected chain parameters will be used."` 9 | RPCUser string `long:"rpcuser" description:"Username for RPC connections"` 10 | RPCPass string `long:"rpcpass" default-mask:"-" description:"Password for RPC connections"` 11 | RPCCert string `long:"rpccert" description:"File containing the daemon's certificate file"` 12 | RawRPCCert string `long:"rawrpccert" description:"The raw bytes of the daemon's PEM-encoded certificate chain which will be used to authenticate the RPC connection."` 13 | } 14 | -------------------------------------------------------------------------------- /lncfg/db_test.go: -------------------------------------------------------------------------------- 1 | package lncfg_test 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/lightningnetwork/lnd/kvdb" 7 | "github.com/lightningnetwork/lnd/lncfg" 8 | "github.com/stretchr/testify/require" 9 | ) 10 | 11 | // TestDBDefaultConfig tests that the default DB config is created as expected. 12 | func TestDBDefaultConfig(t *testing.T) { 13 | defaultConfig := lncfg.DefaultDB() 14 | 15 | require.Equal(t, lncfg.BoltBackend, defaultConfig.Backend) 16 | require.Equal( 17 | t, kvdb.DefaultBoltAutoCompactMinAge, 18 | defaultConfig.Bolt.AutoCompactMinAge, 19 | ) 20 | require.Equal(t, kvdb.DefaultDBTimeout, defaultConfig.Bolt.DBTimeout) 21 | // Implicitly, the following fields are default to false. 22 | require.False(t, defaultConfig.Bolt.AutoCompact) 23 | require.True(t, defaultConfig.Bolt.NoFreelistSync) 24 | } 25 | -------------------------------------------------------------------------------- /lncfg/error.go: -------------------------------------------------------------------------------- 1 | package lncfg 2 | 3 | import "fmt" 4 | 5 | // UsageError is an error type that signals a problem with the supplied flags. 6 | type UsageError struct { 7 | Err error 8 | } 9 | 10 | // Error returns the error string. 11 | // 12 | // NOTE: This is part of the error interface. 13 | func (u *UsageError) Error() string { 14 | return u.Err.Error() 15 | } 16 | 17 | // Unwrap returns the underlying error. 18 | func (u *UsageError) Unwrap() error { 19 | return u.Err 20 | } 21 | 22 | // mkErr creates a new error from a string. 23 | func mkErr(format string, args ...interface{}) error { 24 | return fmt.Errorf(format, args...) 25 | } 26 | -------------------------------------------------------------------------------- /lncfg/interface.go: -------------------------------------------------------------------------------- 1 | package lncfg 2 | 3 | // Validator is a generic interface for validating sub configurations. 4 | type Validator interface { 5 | // Validate returns an error if a particular configuration is invalid or 6 | // insane. 7 | Validate() error 8 | } 9 | 10 | // Validate accepts a variadic list of Validators and checks that each one 11 | // passes its Validate method. An error is returned from the first Validator 12 | // that fails. 13 | func Validate(validators ...Validator) error { 14 | for _, validator := range validators { 15 | if err := validator.Validate(); err != nil { 16 | return err 17 | } 18 | } 19 | 20 | return nil 21 | } 22 | -------------------------------------------------------------------------------- /lncfg/log.go: -------------------------------------------------------------------------------- 1 | package lncfg 2 | 3 | import ( 4 | "github.com/btcsuite/btclog/v2" 5 | "github.com/lightningnetwork/lnd/build" 6 | ) 7 | 8 | // log is a logger that is initialized with no output filters. This 9 | // means the package will not perform any logging by default until the caller 10 | // requests it. 11 | var log btclog.Logger 12 | 13 | // Subsystem defines the logging code for this subsystem. 14 | const Subsystem = "CNFG" 15 | 16 | // The default amount of logging is none. 17 | func init() { 18 | UseLogger(build.NewSubLogger(Subsystem, nil)) 19 | } 20 | 21 | // DisableLog disables all library log output. Logging output is disabled 22 | // by default until UseLogger is called. 23 | func DisableLog() { 24 | UseLogger(btclog.Disabled) 25 | } 26 | 27 | // UseLogger uses a specified Logger to output package logging info. 28 | // This should be used in preference to SetLogWriter if the caller is also 29 | // using btclog. 30 | func UseLogger(logger btclog.Logger) { 31 | log = logger 32 | } 33 | -------------------------------------------------------------------------------- /lncfg/monitoring_off.go: -------------------------------------------------------------------------------- 1 | //go:build !monitoring 2 | // +build !monitoring 3 | 4 | package lncfg 5 | 6 | // Prometheus configures the Prometheus exporter when monitoring is enabled. 7 | // Monitoring is currently disabled. 8 | type Prometheus struct{} 9 | 10 | // DefaultPrometheus is the default configuration for the Prometheus metrics 11 | // exporter when monitoring is enabled. Monitoring is currently disabled. 12 | func DefaultPrometheus() Prometheus { 13 | return Prometheus{} 14 | } 15 | 16 | // Enabled returns whether or not Prometheus monitoring is enabled. Monitoring 17 | // is currently disabled, so Enabled will always return false. 18 | func (p *Prometheus) Enabled() bool { 19 | return false 20 | } 21 | -------------------------------------------------------------------------------- /lncfg/protocol_experimental_off.go: -------------------------------------------------------------------------------- 1 | //go:build !dev 2 | // +build !dev 3 | 4 | package lncfg 5 | 6 | // ExperimentalProtocol is a sub-config that houses any experimental protocol 7 | // features that also require a build-tag to activate. 8 | type ExperimentalProtocol struct { 9 | } 10 | -------------------------------------------------------------------------------- /lncfg/protocol_experimental_on.go: -------------------------------------------------------------------------------- 1 | //go:build dev 2 | // +build dev 3 | 4 | package lncfg 5 | 6 | // ExperimentalProtocol is a sub-config that houses any experimental protocol 7 | // features that also require a build-tag to activate. 8 | type ExperimentalProtocol struct { 9 | } 10 | -------------------------------------------------------------------------------- /lncfg/protocol_legacy_off.go: -------------------------------------------------------------------------------- 1 | //go:build !dev 2 | // +build !dev 3 | 4 | package lncfg 5 | 6 | // Legacy is a sub-config that houses all the legacy protocol options. These 7 | // are mostly used for integration tests as most modern nodes should always run 8 | // with them on by default. 9 | type LegacyProtocol struct { 10 | } 11 | 12 | // LegacyOnion returns true if the old legacy onion format should be used when 13 | // we're an intermediate or final hop. This controls if we set the 14 | // TLVOnionPayloadOptional bit or not. 15 | func (l *LegacyProtocol) LegacyOnion() bool { 16 | return false 17 | } 18 | 19 | // NoStaticRemoteKey returns true if the old commitment format with a tweaked 20 | // remote key should be used for new funded channels. 21 | func (l *LegacyProtocol) NoStaticRemoteKey() bool { 22 | return false 23 | } 24 | -------------------------------------------------------------------------------- /lncfg/watchtower.go: -------------------------------------------------------------------------------- 1 | package lncfg 2 | 3 | import "github.com/lightningnetwork/lnd/watchtower" 4 | 5 | // Watchtower holds the daemon specific configuration parameters for running a 6 | // watchtower that shares resources with the daemon. 7 | // 8 | //nolint:ll 9 | type Watchtower struct { 10 | Active bool `long:"active" description:"If the watchtower should be active or not"` 11 | 12 | TowerDir string `long:"towerdir" description:"Directory of the watchtower.db"` 13 | 14 | watchtower.Conf 15 | } 16 | 17 | // DefaultWatchtowerCfg creates a Watchtower with some default values filled 18 | // out. 19 | func DefaultWatchtowerCfg(defaultTowerDir string) *Watchtower { 20 | conf := watchtower.DefaultConf() 21 | 22 | return &Watchtower{ 23 | TowerDir: defaultTowerDir, 24 | Conf: *conf, 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /lnencrypt/test_utils.go: -------------------------------------------------------------------------------- 1 | package lnencrypt 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/btcsuite/btcd/btcec/v2" 7 | "github.com/lightningnetwork/lnd/keychain" 8 | ) 9 | 10 | var ( 11 | testWalletPrivKey = []byte{ 12 | 0x2b, 0xd8, 0x06, 0xc9, 0x7f, 0x0e, 0x00, 0xaf, 13 | 0x1a, 0x1f, 0xc3, 0x32, 0x8f, 0xa7, 0x63, 0xa9, 14 | 0x26, 0x97, 0x23, 0xc8, 0xdb, 0x8f, 0xac, 0x4f, 15 | 0x93, 0xaf, 0x71, 0xdb, 0x18, 0x6d, 0x6e, 0x90, 16 | } 17 | ) 18 | 19 | type MockKeyRing struct { 20 | Fail bool 21 | } 22 | 23 | func (m *MockKeyRing) DeriveNextKey( 24 | keyFam keychain.KeyFamily) (keychain.KeyDescriptor, error) { 25 | 26 | return keychain.KeyDescriptor{}, nil 27 | } 28 | 29 | func (m *MockKeyRing) DeriveKey( 30 | keyLoc keychain.KeyLocator) (keychain.KeyDescriptor, error) { 31 | 32 | if m.Fail { 33 | return keychain.KeyDescriptor{}, fmt.Errorf("fail") 34 | } 35 | 36 | _, pub := btcec.PrivKeyFromBytes(testWalletPrivKey) 37 | return keychain.KeyDescriptor{ 38 | PubKey: pub, 39 | }, nil 40 | } 41 | -------------------------------------------------------------------------------- /lnmock/clock.go: -------------------------------------------------------------------------------- 1 | // NOTE: forcetypeassert is skipped for the mock because the test would fail if 2 | // the returned value doesn't match the type. 3 | package lnmock 4 | 5 | import ( 6 | "time" 7 | 8 | "github.com/lightningnetwork/lnd/clock" 9 | "github.com/stretchr/testify/mock" 10 | ) 11 | 12 | // MockClock implements the `clock.Clock` interface. 13 | type MockClock struct { 14 | mock.Mock 15 | } 16 | 17 | // Compile time assertion that MockClock implements clock.Clock. 18 | var _ clock.Clock = (*MockClock)(nil) 19 | 20 | func (m *MockClock) Now() time.Time { 21 | args := m.Called() 22 | 23 | return args.Get(0).(time.Time) 24 | } 25 | 26 | func (m *MockClock) TickAfter(d time.Duration) <-chan time.Time { 27 | args := m.Called(d) 28 | 29 | return args.Get(0).(chan time.Time) 30 | } 31 | -------------------------------------------------------------------------------- /lnmock/routing.go: -------------------------------------------------------------------------------- 1 | package lnmock 2 | 3 | import ( 4 | "bytes" 5 | 6 | "github.com/lightningnetwork/lnd/lnwire" 7 | ) 8 | 9 | // MockOnion returns a mock onion payload. 10 | func MockOnion() [lnwire.OnionPacketSize]byte { 11 | var onion [lnwire.OnionPacketSize]byte 12 | onionBlob := bytes.Repeat([]byte{1}, lnwire.OnionPacketSize) 13 | copy(onion[:], onionBlob) 14 | 15 | return onion 16 | } 17 | -------------------------------------------------------------------------------- /lnpeer/errors.go: -------------------------------------------------------------------------------- 1 | package lnpeer 2 | 3 | import "fmt" 4 | 5 | var ( 6 | // ErrPeerExiting signals that the peer received a disconnect request. 7 | ErrPeerExiting = fmt.Errorf("peer exiting") 8 | ) 9 | -------------------------------------------------------------------------------- /lnrpc/.clang-format: -------------------------------------------------------------------------------- 1 | --- 2 | Language: Proto 3 | BasedOnStyle: Google 4 | IndentWidth: 4 5 | AllowShortFunctionsOnASingleLine: None 6 | SpaceBeforeParens: Always 7 | CompactNamespaces: false 8 | -------------------------------------------------------------------------------- /lnrpc/autopilotrpc/autopilot.yaml: -------------------------------------------------------------------------------- 1 | type: google.api.Service 2 | config_version: 3 3 | 4 | http: 5 | rules: 6 | - selector: autopilotrpc.Autopilot.Status 7 | get: "/v2/autopilot/status" 8 | - selector: autopilotrpc.Autopilot.ModifyStatus 9 | post: "/v2/autopilot/modify" 10 | body: "*" 11 | - selector: autopilotrpc.Autopilot.QueryScores 12 | get: "/v2/autopilot/scores" 13 | - selector: autopilotrpc.Autopilot.SetScores 14 | post: "/v2/autopilot/scores" 15 | body: "*" 16 | -------------------------------------------------------------------------------- /lnrpc/autopilotrpc/config_active.go: -------------------------------------------------------------------------------- 1 | //go:build autopilotrpc 2 | // +build autopilotrpc 3 | 4 | package autopilotrpc 5 | 6 | import ( 7 | "github.com/lightningnetwork/lnd/autopilot" 8 | ) 9 | 10 | // Config is the primary configuration struct for the autopilot RPC server. It 11 | // contains all the items required for the rpc server to carry out its 12 | // duties. The fields with struct tags are meant to be parsed as normal 13 | // configuration options, while if able to be populated, the latter fields MUST 14 | // also be specified. 15 | type Config struct { 16 | // Manager is the running autopilot manager. 17 | Manager *autopilot.Manager 18 | } 19 | -------------------------------------------------------------------------------- /lnrpc/autopilotrpc/config_default.go: -------------------------------------------------------------------------------- 1 | //go:build !autopilotrpc 2 | // +build !autopilotrpc 3 | 4 | package autopilotrpc 5 | 6 | // Config is empty for non-autopilotrpc builds. 7 | type Config struct{} 8 | -------------------------------------------------------------------------------- /lnrpc/autopilotrpc/log.go: -------------------------------------------------------------------------------- 1 | package autopilotrpc 2 | 3 | import ( 4 | "github.com/btcsuite/btclog/v2" 5 | "github.com/lightningnetwork/lnd/build" 6 | ) 7 | 8 | // log is a logger that is initialized with no output filters. This means the 9 | // package will not perform any logging by default until the caller requests 10 | // it. 11 | var log btclog.Logger 12 | 13 | // The default amount of logging is none. 14 | func init() { 15 | UseLogger(build.NewSubLogger("ARPC", nil)) 16 | } 17 | 18 | // DisableLog disables all library log output. Logging output is disabled by 19 | // by default until UseLogger is called. 20 | func DisableLog() { 21 | UseLogger(btclog.Disabled) 22 | } 23 | 24 | // UseLogger uses a specified Logger to output package logging info. This 25 | // should be used in preference to SetLogWriter if the caller is also using 26 | // btclog. 27 | func UseLogger(logger btclog.Logger) { 28 | log = logger 29 | } 30 | -------------------------------------------------------------------------------- /lnrpc/chainrpc/chainkit.yaml: -------------------------------------------------------------------------------- 1 | type: google.api.Service 2 | config_version: 3 3 | 4 | http: 5 | rules: 6 | - selector: chainrpc.ChainKit.GetBlock 7 | get: "/v2/chainkit/block" 8 | - selector: chainrpc.ChainKit.GetBlockHeader 9 | get: "/v2/chainkit/blockheader" 10 | - selector: chainrpc.ChainKit.GetBestBlock 11 | get: "/v2/chainkit/bestblock" 12 | - selector: chainrpc.ChainKit.GetBlockHash 13 | get: "/v2/chainkit/blockhash" -------------------------------------------------------------------------------- /lnrpc/chainrpc/chainnotifier.yaml: -------------------------------------------------------------------------------- 1 | type: google.api.Service 2 | config_version: 3 3 | 4 | http: 5 | rules: 6 | - selector: chainrpc.ChainNotifier.RegisterConfirmationsNtfn 7 | post: "/v2/chainnotifier/register/confirmations" 8 | body: "*" 9 | - selector: chainrpc.ChainNotifier.RegisterSpendNtfn 10 | post: "/v2/chainnotifier/register/spends" 11 | body: "*" 12 | - selector: chainrpc.ChainNotifier.RegisterBlockEpochNtfn 13 | post: "/v2/chainnotifier/register/blocks" 14 | body: "*" 15 | -------------------------------------------------------------------------------- /lnrpc/chainrpc/config_default.go: -------------------------------------------------------------------------------- 1 | //go:build !chainrpc 2 | // +build !chainrpc 3 | 4 | package chainrpc 5 | 6 | // Config is empty for non-chainrpc builds. 7 | type Config struct{} 8 | -------------------------------------------------------------------------------- /lnrpc/chainrpc/log.go: -------------------------------------------------------------------------------- 1 | package chainrpc 2 | 3 | import ( 4 | "github.com/btcsuite/btclog/v2" 5 | "github.com/lightningnetwork/lnd/build" 6 | ) 7 | 8 | // log is a logger that is initialized with no output filters. This 9 | // means the package will not perform any logging by default until the caller 10 | // requests it. 11 | var log btclog.Logger 12 | 13 | // The default amount of logging is none. 14 | func init() { 15 | UseLogger(build.NewSubLogger("NTFR", nil)) 16 | } 17 | 18 | // DisableLog disables all library log output. Logging output is disabled 19 | // by default until UseLogger is called. 20 | func DisableLog() { 21 | UseLogger(btclog.Disabled) 22 | } 23 | 24 | // UseLogger uses a specified Logger to output package logging info. 25 | // This should be used in preference to SetLogWriter if the caller is also 26 | // using btclog. 27 | func UseLogger(logger btclog.Logger) { 28 | log = logger 29 | } 30 | -------------------------------------------------------------------------------- /lnrpc/devrpc/config_active.go: -------------------------------------------------------------------------------- 1 | //go:build dev 2 | // +build dev 3 | 4 | package devrpc 5 | 6 | import ( 7 | "github.com/btcsuite/btcd/chaincfg" 8 | graphdb "github.com/lightningnetwork/lnd/graph/db" 9 | "github.com/lightningnetwork/lnd/htlcswitch" 10 | ) 11 | 12 | // Config is the primary configuration struct for the DEV RPC server. It 13 | // contains all the items required for the rpc server to carry out its 14 | // duties. Any fields with struct tags are meant to be parsed as normal 15 | // configuration options, while if able to be populated, the latter fields MUST 16 | // also be specified. 17 | type Config struct { 18 | ActiveNetParams *chaincfg.Params 19 | GraphDB *graphdb.ChannelGraph 20 | Switch *htlcswitch.Switch 21 | } 22 | -------------------------------------------------------------------------------- /lnrpc/devrpc/config_default.go: -------------------------------------------------------------------------------- 1 | //go:build !dev 2 | // +build !dev 3 | 4 | package devrpc 5 | 6 | // Config is empty for non-devrpc builds. 7 | type Config struct{} 8 | -------------------------------------------------------------------------------- /lnrpc/devrpc/dev.yaml: -------------------------------------------------------------------------------- 1 | type: google.api.Service 2 | config_version: 3 3 | 4 | http: 5 | rules: 6 | - selector: devrpc.Dev.ImportGraph 7 | post: "/v2/dev/importgraph" 8 | body: "*" 9 | - selector: devrpc.Dev.Quiesce 10 | post: "/v2/dev/quiesce" 11 | body: "*" 12 | -------------------------------------------------------------------------------- /lnrpc/devrpc/log.go: -------------------------------------------------------------------------------- 1 | package devrpc 2 | 3 | import ( 4 | "github.com/btcsuite/btclog/v2" 5 | "github.com/lightningnetwork/lnd/build" 6 | ) 7 | 8 | // log is a logger that is initialized with no output filters. This means the 9 | // package will not perform any logging by default until the caller requests 10 | // it. 11 | var log btclog.Logger 12 | 13 | // The default amount of logging is none. 14 | func init() { 15 | UseLogger(build.NewSubLogger("DRPC", nil)) 16 | } 17 | 18 | // DisableLog disables all library log output. Logging output is disabled by 19 | // by default until UseLogger is called. 20 | func DisableLog() { 21 | UseLogger(btclog.Disabled) 22 | } 23 | 24 | // UseLogger uses a specified Logger to output package logging info. This 25 | // should be used in preference to SetLogWriter if the caller is also using 26 | // btclog. 27 | func UseLogger(logger btclog.Logger) { 28 | log = logger 29 | } 30 | -------------------------------------------------------------------------------- /lnrpc/file_utils.go: -------------------------------------------------------------------------------- 1 | package lnrpc 2 | 3 | import ( 4 | "os" 5 | ) 6 | 7 | // FileExists reports whether the named file or directory exists. 8 | func FileExists(name string) bool { 9 | if _, err := os.Stat(name); err != nil { 10 | if os.IsNotExist(err) { 11 | return false 12 | } 13 | } 14 | return true 15 | } 16 | -------------------------------------------------------------------------------- /lnrpc/invoicesrpc/config_default.go: -------------------------------------------------------------------------------- 1 | //go:build !invoicesrpc 2 | // +build !invoicesrpc 3 | 4 | package invoicesrpc 5 | 6 | // Config is empty for non-invoicesrpc builds. 7 | type Config struct{} 8 | -------------------------------------------------------------------------------- /lnrpc/invoicesrpc/interfaces.go: -------------------------------------------------------------------------------- 1 | package invoicesrpc 2 | 3 | import ( 4 | "github.com/lightningnetwork/lnd/graph/db/models" 5 | ) 6 | 7 | // GraphSource defines the graph interface required by the invoice rpc server. 8 | type GraphSource interface { 9 | // FetchChannelEdgesByID attempts to look up the two directed edges for 10 | // the channel identified by the channel ID. If the channel can't be 11 | // found, then graphdb.ErrEdgeNotFound is returned. 12 | FetchChannelEdgesByID(chanID uint64) (*models.ChannelEdgeInfo, 13 | *models.ChannelEdgePolicy, *models.ChannelEdgePolicy, error) 14 | 15 | // IsPublicNode is a helper method that determines whether the node with 16 | // the given public key is seen as a public node in the graph from the 17 | // graph's source node's point of view. 18 | IsPublicNode(pubKey [33]byte) (bool, error) 19 | } 20 | -------------------------------------------------------------------------------- /lnrpc/invoicesrpc/invoices.yaml: -------------------------------------------------------------------------------- 1 | type: google.api.Service 2 | config_version: 3 3 | 4 | http: 5 | rules: 6 | - selector: invoicesrpc.Invoices.SubscribeSingleInvoice 7 | get: "/v2/invoices/subscribe/{r_hash}" 8 | - selector: invoicesrpc.Invoices.CancelInvoice 9 | post: "/v2/invoices/cancel" 10 | body: "*" 11 | - selector: invoicesrpc.Invoices.AddHoldInvoice 12 | post: "/v2/invoices/hodl" 13 | body: "*" 14 | - selector: invoicesrpc.Invoices.SettleInvoice 15 | post: "/v2/invoices/settle" 16 | body: "*" 17 | - selector: invoicesrpc.Invoices.LookupInvoiceV2 18 | get: "/v2/invoices/lookup" 19 | - selector: invoicesrpc.Invoices.HtlcModifier 20 | post: "/v2/invoices/htlcmodifier" 21 | body: "*" -------------------------------------------------------------------------------- /lnrpc/invoicesrpc/log.go: -------------------------------------------------------------------------------- 1 | package invoicesrpc 2 | 3 | import ( 4 | "github.com/btcsuite/btclog/v2" 5 | "github.com/lightningnetwork/lnd/build" 6 | ) 7 | 8 | // log is a logger that is initialized with no output filters. This means the 9 | // package will not perform any logging by default until the caller requests 10 | // it. 11 | var log btclog.Logger 12 | 13 | // The default amount of logging is none. 14 | func init() { 15 | UseLogger(build.NewSubLogger("IRPC", nil)) 16 | } 17 | 18 | // DisableLog disables all library log output. Logging output is disabled by 19 | // by default until UseLogger is called. 20 | func DisableLog() { 21 | UseLogger(btclog.Disabled) 22 | } 23 | 24 | // UseLogger uses a specified Logger to output package logging info. This 25 | // should be used in preference to SetLogWriter if the caller is also using 26 | // btclog. 27 | func UseLogger(logger btclog.Logger) { 28 | log = logger 29 | } 30 | -------------------------------------------------------------------------------- /lnrpc/lnclipb/lncli.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package lnclipb; 4 | 5 | import "verrpc/verrpc.proto"; 6 | 7 | option go_package = "github.com/lightningnetwork/lnd/lnrpc/lnclipb"; 8 | 9 | message VersionResponse { 10 | // The version information for lncli. 11 | verrpc.Version lncli = 1; 12 | 13 | // The version information for lnd. 14 | verrpc.Version lnd = 2; 15 | }; 16 | -------------------------------------------------------------------------------- /lnrpc/lnclipb/lncli.yaml: -------------------------------------------------------------------------------- 1 | type: google.api.Service 2 | config_version: 3 3 | 4 | http: 5 | rules: 6 | -------------------------------------------------------------------------------- /lnrpc/metadata.go: -------------------------------------------------------------------------------- 1 | package lnrpc 2 | 3 | import "regexp" 4 | 5 | var ( 6 | // LndClientStreamingURIs is a list of all lnd RPCs that use a request- 7 | // streaming interface. Those request-streaming RPCs need to be handled 8 | // differently in the WebsocketProxy because of how the request body 9 | // parsing is implemented in the grpc-gateway library. Unfortunately 10 | // there is no straightforward way of obtaining this information on 11 | // runtime so we need to keep a hard coded list here. 12 | LndClientStreamingURIs = []*regexp.Regexp{ 13 | regexp.MustCompile("^/v1/channels/acceptor$"), 14 | regexp.MustCompile("^/v1/channels/transaction-stream$"), 15 | regexp.MustCompile("^/v2/router/htlcinterceptor$"), 16 | regexp.MustCompile("^/v1/middleware$"), 17 | } 18 | 19 | // MaxGrpcMsgSize is used when we configure both server and clients to 20 | // allow sending/receiving at most 200 MiB GRPC messages. 21 | MaxGrpcMsgSize = 200 * 1024 * 1024 22 | ) 23 | -------------------------------------------------------------------------------- /lnrpc/neutrinorpc/config_active.go: -------------------------------------------------------------------------------- 1 | //go:build neutrinorpc 2 | // +build neutrinorpc 3 | 4 | package neutrinorpc 5 | 6 | import ( 7 | "github.com/lightninglabs/neutrino" 8 | ) 9 | 10 | // Config is the primary configuration struct for the neutrino RPC server. It 11 | // contains all the items required for the rpc server to carry out its 12 | // duties. The fields with struct tags are meant to be parsed as normal 13 | // configuration options, while if able to be populated, the latter fields MUST 14 | // also be specified. 15 | type Config struct { 16 | // ChainService is required to handle neutrino chain service requests. 17 | NeutrinoCS *neutrino.ChainService 18 | } 19 | -------------------------------------------------------------------------------- /lnrpc/neutrinorpc/config_default.go: -------------------------------------------------------------------------------- 1 | //go:build !neutrinorpc 2 | // +build !neutrinorpc 3 | 4 | package neutrinorpc 5 | 6 | // Config is empty for non-neutrinorpc builds. 7 | type Config struct{} 8 | -------------------------------------------------------------------------------- /lnrpc/neutrinorpc/neutrino.yaml: -------------------------------------------------------------------------------- 1 | type: google.api.Service 2 | config_version: 3 3 | 4 | http: 5 | rules: 6 | - selector: neutrinorpc.NeutrinoKit.Status 7 | get: "/v2/neutrino/status" 8 | - selector: neutrinorpc.NeutrinoKit.AddPeer 9 | post: "/v2/neutrino/addpeer" 10 | body: "*" 11 | - selector: neutrinorpc.NeutrinoKit.DisconnectPeer 12 | post: "/v2/neutrino/disconnect" 13 | body: "*" 14 | - selector: neutrinorpc.NeutrinoKit.IsBanned 15 | get: "/v2/neutrino/isbanned" 16 | - selector: neutrinorpc.NeutrinoKit.GetBlock 17 | get: "/v2/neutrino/block/{hash}" 18 | - selector: neutrinorpc.NeutrinoKit.GetBlockHeader 19 | get: "/v2/neutrino/blockheader/{hash}" 20 | - selector: neutrinorpc.NeutrinoKit.GetCFilter 21 | get: "/v2/neutrino/cfilter/{hash}" 22 | # deprecated 23 | - selector: neutrinorpc.NeutrinoKit.GetBlockHash 24 | get: "/v2/neutrino/blockhash/{height}" 25 | -------------------------------------------------------------------------------- /lnrpc/peersrpc/config_default.go: -------------------------------------------------------------------------------- 1 | //go:build !peersrpc 2 | // +build !peersrpc 3 | 4 | package peersrpc 5 | 6 | // Config is empty for non-peersrpc builds. 7 | type Config struct{} 8 | -------------------------------------------------------------------------------- /lnrpc/peersrpc/log.go: -------------------------------------------------------------------------------- 1 | package peersrpc 2 | 3 | import ( 4 | "github.com/btcsuite/btclog/v2" 5 | "github.com/lightningnetwork/lnd/build" 6 | ) 7 | 8 | // log is a logger that is initialized with no output filters. This means the 9 | // package will not perform any logging by default until the caller requests 10 | // it. 11 | var log btclog.Logger 12 | 13 | // Subsystem defines the logging code for this subsystem. 14 | const Subsystem = "PRPC" 15 | 16 | // The default amount of logging is none. 17 | func init() { 18 | UseLogger(build.NewSubLogger(Subsystem, nil)) 19 | } 20 | 21 | // DisableLog disables all library log output. Logging output is disabled by 22 | // by default until UseLogger is called. 23 | func DisableLog() { 24 | UseLogger(btclog.Disabled) 25 | } 26 | 27 | // UseLogger uses a specified Logger to output package logging info. This 28 | // should be used in preference to SetLogWriter if the caller is also using 29 | // btclog. 30 | func UseLogger(logger btclog.Logger) { 31 | log = logger 32 | } 33 | -------------------------------------------------------------------------------- /lnrpc/peersrpc/peers.yaml: -------------------------------------------------------------------------------- 1 | type: google.api.Service 2 | config_version: 3 3 | 4 | http: 5 | rules: 6 | - selector: peersrpc.Peers.UpdateNodeAnnouncement 7 | post: "/v2/peers/nodeannouncement" 8 | body: "*" 9 | -------------------------------------------------------------------------------- /lnrpc/routerrpc/log.go: -------------------------------------------------------------------------------- 1 | package routerrpc 2 | 3 | import ( 4 | "github.com/btcsuite/btclog/v2" 5 | "github.com/lightningnetwork/lnd/build" 6 | ) 7 | 8 | // log is a logger that is initialized with no output filters. This 9 | // means the package will not perform any logging by default until the caller 10 | // requests it. 11 | var log btclog.Logger 12 | 13 | // Subsystem defines the logging code for this subsystem. 14 | const Subsystem = "RRPC" 15 | 16 | // The default amount of logging is none. 17 | func init() { 18 | UseLogger(build.NewSubLogger(Subsystem, nil)) 19 | } 20 | 21 | // DisableLog disables all library log output. Logging output is disabled 22 | // by default until UseLogger is called. 23 | func DisableLog() { 24 | UseLogger(btclog.Disabled) 25 | } 26 | 27 | // UseLogger uses a specified Logger to output package logging info. 28 | // This should be used in preference to SetLogWriter if the caller is also 29 | // using btclog. 30 | func UseLogger(logger btclog.Logger) { 31 | log = logger 32 | } 33 | -------------------------------------------------------------------------------- /lnrpc/signrpc/config_default.go: -------------------------------------------------------------------------------- 1 | //go:build !signrpc 2 | // +build !signrpc 3 | 4 | package signrpc 5 | 6 | // Config is empty for non-signrpc builds. 7 | type Config struct{} 8 | -------------------------------------------------------------------------------- /lnrpc/signrpc/log.go: -------------------------------------------------------------------------------- 1 | package signrpc 2 | 3 | import ( 4 | "github.com/btcsuite/btclog/v2" 5 | "github.com/lightningnetwork/lnd/build" 6 | ) 7 | 8 | // log is a logger that is initialized with no output filters. This 9 | // means the package will not perform any logging by default until the caller 10 | // requests it. 11 | var log btclog.Logger 12 | 13 | // The default amount of logging is none. 14 | func init() { 15 | UseLogger(build.NewSubLogger("SGNR", nil)) 16 | } 17 | 18 | // DisableLog disables all library log output. Logging output is disabled 19 | // by default until UseLogger is called. 20 | func DisableLog() { 21 | UseLogger(btclog.Disabled) 22 | } 23 | 24 | // UseLogger uses a specified Logger to output package logging info. 25 | // This should be used in preference to SetLogWriter if the caller is also 26 | // using btclog. 27 | func UseLogger(logger btclog.Logger) { 28 | log = logger 29 | } 30 | -------------------------------------------------------------------------------- /lnrpc/stateservice.yaml: -------------------------------------------------------------------------------- 1 | type: google.api.Service 2 | config_version: 3 3 | 4 | http: 5 | rules: 6 | - selector: lnrpc.State.SubscribeState 7 | get: "/v1/state/subscribe" 8 | - selector: lnrpc.State.GetState 9 | get: "/v1/state" 10 | -------------------------------------------------------------------------------- /lnrpc/verrpc/driver.go: -------------------------------------------------------------------------------- 1 | package verrpc 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/lightningnetwork/lnd/lnrpc" 7 | ) 8 | 9 | func init() { 10 | subServer := &lnrpc.SubServerDriver{ 11 | SubServerName: subServerName, 12 | NewGrpcHandler: func() lnrpc.GrpcHandler { 13 | return &ServerShell{} 14 | }, 15 | } 16 | 17 | // We'll register ourselves as a sub-RPC server within the global lnrpc 18 | // package namespace. 19 | if err := lnrpc.RegisterSubServer(subServer); err != nil { 20 | panic(fmt.Sprintf("failed to register sub server driver '%s': %v", 21 | subServerName, err)) 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /lnrpc/verrpc/log.go: -------------------------------------------------------------------------------- 1 | package verrpc 2 | 3 | import ( 4 | "github.com/btcsuite/btclog/v2" 5 | "github.com/lightningnetwork/lnd/build" 6 | ) 7 | 8 | // log is a logger that is initialized with no output filters. This 9 | // means the package will not perform any logging by default until the caller 10 | // requests it. 11 | var log btclog.Logger 12 | 13 | // Subsystem defines the logging code for this subsystem. 14 | const Subsystem = "VRPC" 15 | 16 | // The default amount of logging is none. 17 | func init() { 18 | UseLogger(build.NewSubLogger(Subsystem, nil)) 19 | } 20 | 21 | // DisableLog disables all library log output. Logging output is disabled 22 | // by default until UseLogger is called. 23 | func DisableLog() { 24 | UseLogger(btclog.Disabled) 25 | } 26 | 27 | // UseLogger uses a specified Logger to output package logging info. 28 | // This should be used in preference to SetLogWriter if the caller is also 29 | // using btclog. 30 | func UseLogger(logger btclog.Logger) { 31 | log = logger 32 | } 33 | -------------------------------------------------------------------------------- /lnrpc/verrpc/verrpc.yaml: -------------------------------------------------------------------------------- 1 | type: google.api.Service 2 | config_version: 3 3 | 4 | http: 5 | rules: 6 | - selector: verrpc.Versioner.GetVersion 7 | get: "/v2/versioner/version" 8 | -------------------------------------------------------------------------------- /lnrpc/walletrpc/config_default.go: -------------------------------------------------------------------------------- 1 | //go:build !walletrpc 2 | // +build !walletrpc 3 | 4 | package walletrpc 5 | 6 | const ( 7 | // SubServerName is the name of the sub rpc server. We'll use this name 8 | // to register ourselves, and we also require that the main 9 | // SubServerConfigDispatcher instance recognize as the name of our 10 | SubServerName = "WalletKitRPC" 11 | ) 12 | 13 | // Config is the primary configuration struct for the WalletKit RPC server. 14 | // When the server isn't active (via the build flag), callers outside this 15 | // package will see this shell of a config file. 16 | type Config struct{} 17 | -------------------------------------------------------------------------------- /lnrpc/walletrpc/errors.go: -------------------------------------------------------------------------------- 1 | package walletrpc 2 | 3 | import "errors" 4 | 5 | var ( 6 | 7 | // ErrZeroLabel is returned when an attempt is made to label a 8 | // transaction with an empty label. 9 | ErrZeroLabel = errors.New("cannot label transaction with empty " + 10 | "label") 11 | 12 | // ErrInsufficientReserve is returned when SendOutputs wouldn't leave 13 | // enough funds in the wallet to cover for the anchor reserve. 14 | ErrInsufficientReserve = errors.New("the outputs to be sent " + 15 | "would leave insufficient reserves for anchor channels in " + 16 | "the wallet") 17 | ) 18 | -------------------------------------------------------------------------------- /lnrpc/walletrpc/log.go: -------------------------------------------------------------------------------- 1 | package walletrpc 2 | 3 | import ( 4 | "github.com/btcsuite/btclog/v2" 5 | "github.com/lightningnetwork/lnd/build" 6 | ) 7 | 8 | // log is a logger that is initialized with no output filters. This means the 9 | // package will not perform any logging by default until the caller requests 10 | // it. 11 | var log btclog.Logger 12 | 13 | // The default amount of logging is none. 14 | func init() { 15 | UseLogger(build.NewSubLogger("WLKT", nil)) 16 | } 17 | 18 | // DisableLog disables all library log output. Logging output is disabled by 19 | // by default until UseLogger is called. 20 | func DisableLog() { 21 | UseLogger(btclog.Disabled) 22 | } 23 | 24 | // UseLogger uses a specified Logger to output package logging info. This 25 | // should be used in preference to SetLogWriter if the caller is also using 26 | // btclog. 27 | func UseLogger(logger btclog.Logger) { 28 | log = logger 29 | } 30 | -------------------------------------------------------------------------------- /lnrpc/walletunlocker.yaml: -------------------------------------------------------------------------------- 1 | type: google.api.Service 2 | config_version: 3 3 | 4 | http: 5 | rules: 6 | - selector: lnrpc.WalletUnlocker.GenSeed 7 | get: "/v1/genseed" 8 | - selector: lnrpc.WalletUnlocker.InitWallet 9 | post: "/v1/initwallet" 10 | body: "*" 11 | - selector: lnrpc.WalletUnlocker.UnlockWallet 12 | post: "/v1/unlockwallet" 13 | body: "*" 14 | - selector: lnrpc.WalletUnlocker.ChangePassword 15 | post: "/v1/changepassword" 16 | body: "*" 17 | -------------------------------------------------------------------------------- /lnrpc/watchtowerrpc/config_active.go: -------------------------------------------------------------------------------- 1 | //go:build watchtowerrpc 2 | // +build watchtowerrpc 3 | 4 | package watchtowerrpc 5 | 6 | // Config is the primary configuration struct for the watchtower RPC server. It 7 | // contains all items required for the RPC server to carry out its duties. The 8 | // fields with struct tags are meant to parsed as normal configuration options, 9 | // while if able to be populated, the latter fields MUST also be specified. 10 | type Config struct { 11 | // Active indicates if the watchtower is enabled. 12 | Active bool 13 | 14 | // Tower is the active watchtower which serves as the primary source for 15 | // information presented via RPC. 16 | Tower WatchtowerBackend 17 | } 18 | -------------------------------------------------------------------------------- /lnrpc/watchtowerrpc/config_default.go: -------------------------------------------------------------------------------- 1 | //go:build !watchtowerrpc 2 | // +build !watchtowerrpc 3 | 4 | package watchtowerrpc 5 | 6 | // Config is empty for non-watchtowerrpc builds. 7 | type Config struct{} 8 | -------------------------------------------------------------------------------- /lnrpc/watchtowerrpc/interface.go: -------------------------------------------------------------------------------- 1 | package watchtowerrpc 2 | 3 | import ( 4 | "net" 5 | 6 | "github.com/btcsuite/btcd/btcec/v2" 7 | ) 8 | 9 | // WatchtowerBackend abstracts access to the watchtower information that is 10 | // served via RPC connections. 11 | type WatchtowerBackend interface { 12 | // PubKey returns the public key for the watchtower used to 13 | // authentication and encrypt traffic with clients. 14 | PubKey() *btcec.PublicKey 15 | 16 | // ListeningAddrs returns the listening addresses where the watchtower 17 | // server can accept client connections. 18 | ListeningAddrs() []net.Addr 19 | 20 | // ExternalIPs returns the addresses where the watchtower can be reached 21 | // by clients externally. 22 | ExternalIPs() []net.Addr 23 | } 24 | -------------------------------------------------------------------------------- /lnrpc/watchtowerrpc/log.go: -------------------------------------------------------------------------------- 1 | package watchtowerrpc 2 | 3 | import ( 4 | "github.com/btcsuite/btclog/v2" 5 | "github.com/lightningnetwork/lnd/build" 6 | ) 7 | 8 | // Subsystem defines the logging code for this subsystem. 9 | const Subsystem = "WRPC" 10 | 11 | // log is a logger that is initialized with no output filters. This means the 12 | // package will not perform any logging by default until the caller requests it. 13 | var log btclog.Logger 14 | 15 | // The default amount of logging is none. 16 | func init() { 17 | UseLogger(build.NewSubLogger(Subsystem, nil)) 18 | } 19 | 20 | // DisableLog disables all library log output. Logging output is disabled by by 21 | // default until UseLogger is called. 22 | func DisableLog() { 23 | UseLogger(btclog.Disabled) 24 | } 25 | 26 | // UseLogger uses a specified Logger to output package logging info. This 27 | // should be used in preference to SetLogWriter if the caller is also using 28 | // btclog. 29 | func UseLogger(logger btclog.Logger) { 30 | log = logger 31 | } 32 | -------------------------------------------------------------------------------- /lnrpc/watchtowerrpc/watchtower.yaml: -------------------------------------------------------------------------------- 1 | type: google.api.Service 2 | config_version: 3 3 | 4 | http: 5 | rules: 6 | - selector: watchtowerrpc.Watchtower.GetInfo 7 | get: "/v2/watchtower/server" 8 | -------------------------------------------------------------------------------- /lnrpc/wtclientrpc/wtclient.yaml: -------------------------------------------------------------------------------- 1 | type: google.api.Service 2 | config_version: 3 3 | 4 | http: 5 | rules: 6 | - selector: wtclientrpc.WatchtowerClient.AddTower 7 | post: "/v2/watchtower/client" 8 | body: "*" 9 | - selector: wtclientrpc.WatchtowerClient.RemoveTower 10 | delete: "/v2/watchtower/client/{pubkey}" 11 | - selector: wtclientrpc.WatchtowerClient.DeactivateTower 12 | post: "/v2/watchtower/client/tower/deactivate/{pubkey}" 13 | - selector: wtclientrpc.WatchtowerClient.TerminateSession 14 | post: "/v2/watchtower/client/sessions/terminate/{session_id}" 15 | - selector: wtclientrpc.WatchtowerClient.ListTowers 16 | get: "/v2/watchtower/client" 17 | - selector: wtclientrpc.WatchtowerClient.GetTowerInfo 18 | get: "/v2/watchtower/client/info/{pubkey}" 19 | - selector: wtclientrpc.WatchtowerClient.Stats 20 | get: "/v2/watchtower/client/stats" 21 | - selector: wtclientrpc.WatchtowerClient.Policy 22 | get: "/v2/watchtower/client/policy" 23 | -------------------------------------------------------------------------------- /lntest/bitcoind.go: -------------------------------------------------------------------------------- 1 | //go:build bitcoind && !notxindex && !rpcpolling 2 | // +build bitcoind,!notxindex,!rpcpolling 3 | 4 | package lntest 5 | 6 | import ( 7 | "github.com/btcsuite/btcd/chaincfg" 8 | ) 9 | 10 | // NewBackend starts a bitcoind node with the txindex enabled and returns a 11 | // BitcoindBackendConfig for that node. 12 | func NewBackend(miner string, netParams *chaincfg.Params) ( 13 | *BitcoindBackendConfig, func() error, error) { 14 | 15 | extraArgs := []string{ 16 | "-regtest", 17 | "-txindex", 18 | "-disablewallet", 19 | } 20 | 21 | return newBackend(miner, netParams, extraArgs, false) 22 | } 23 | -------------------------------------------------------------------------------- /lntest/bitcoind_notxindex.go: -------------------------------------------------------------------------------- 1 | //go:build bitcoind && notxindex && !rpcpolling 2 | // +build bitcoind,notxindex,!rpcpolling 3 | 4 | package lntest 5 | 6 | import ( 7 | "github.com/btcsuite/btcd/chaincfg" 8 | ) 9 | 10 | // NewBackend starts a bitcoind node without the txindex enabled and returns a 11 | // BitoindBackendConfig for that node. 12 | func NewBackend(miner string, netParams *chaincfg.Params) ( 13 | *BitcoindBackendConfig, func() error, error) { 14 | 15 | extraArgs := []string{ 16 | "-regtest", 17 | "-disablewallet", 18 | } 19 | 20 | return newBackend(miner, netParams, extraArgs, false) 21 | } 22 | -------------------------------------------------------------------------------- /lntest/bitcoind_rpcpolling.go: -------------------------------------------------------------------------------- 1 | //go:build bitcoind && rpcpolling 2 | // +build bitcoind,rpcpolling 3 | 4 | package lntest 5 | 6 | import ( 7 | "github.com/btcsuite/btcd/chaincfg" 8 | ) 9 | 10 | // NewBackend starts a bitcoind node without the txindex enabled and returns a 11 | // BitoindBackendConfig for that node. 12 | func NewBackend(miner string, netParams *chaincfg.Params) ( 13 | *BitcoindBackendConfig, func() error, error) { 14 | 15 | extraArgs := []string{ 16 | "-regtest", 17 | "-txindex", 18 | "-disablewallet", 19 | } 20 | 21 | return newBackend(miner, netParams, extraArgs, true) 22 | } 23 | -------------------------------------------------------------------------------- /lntest/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Package lntest provides testing utilities for the lnd repository. 3 | 4 | This package contains infrastructure for integration tests that launch full lnd 5 | nodes in a controlled environment and interact with them via RPC. Using a 6 | NetworkHarness, a test can launch multiple lnd nodes, open channels between 7 | them, create defined network topologies, and anything else that is possible with 8 | RPC commands. 9 | */ 10 | package lntest 11 | -------------------------------------------------------------------------------- /lntest/rpc/state.go: -------------------------------------------------------------------------------- 1 | package rpc 2 | 3 | import ( 4 | "github.com/lightningnetwork/lnd/lnrpc" 5 | ) 6 | 7 | // ===================== 8 | // StateClient related RPCs. 9 | // ===================== 10 | 11 | // SubscribeState makes a rpc call to StateClient and asserts there's no error. 12 | func (h *HarnessRPC) SubscribeState() lnrpc.State_SubscribeStateClient { 13 | client, err := h.State.SubscribeState( 14 | h.runCtx, &lnrpc.SubscribeStateRequest{}, 15 | ) 16 | h.NoError(err, "SubscribeState") 17 | 18 | return client 19 | } 20 | -------------------------------------------------------------------------------- /lntypes/txsize_test.go: -------------------------------------------------------------------------------- 1 | package lntypes 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/stretchr/testify/require" 7 | ) 8 | 9 | // TestTxSizeUnit tests the conversion of tx size to different units. 10 | func TestTxSizeUnit(t *testing.T) { 11 | t.Parallel() 12 | 13 | // Test normal conversion from 100wu to 25vb. 14 | wu := WeightUnit(100) 15 | vb := VByte(25) 16 | require.Equal(t, vb, wu.ToVB(), "wu -> vb conversion "+ 17 | "failed: want %v, got %v", vb, wu.ToVB()) 18 | require.Equal(t, wu, vb.ToWU(), "vb -> wu conversion "+ 19 | "failed: want %v, got %v", wu, vb.ToWU()) 20 | 21 | // Test rounding up conversion from 99wu to 25vb. 22 | wu = WeightUnit(99) 23 | vb = VByte(25) 24 | require.Equal(t, vb, wu.ToVB(), "wu -> vb conversion "+ 25 | "failed: want %v, got %v", vb, wu.ToVB()) 26 | require.Equal(t, WeightUnit(100), vb.ToWU(), "vb -> wu conversion "+ 27 | "failed: want %v, got %v", 100, vb.ToWU()) 28 | } 29 | -------------------------------------------------------------------------------- /lnutils/README.md: -------------------------------------------------------------------------------- 1 | # `lnutils` 2 | 3 | This package provides fundamental types and utility functions that can be used 4 | by all other packages. 5 | -------------------------------------------------------------------------------- /lnutils/chan.go: -------------------------------------------------------------------------------- 1 | package lnutils 2 | 3 | import ( 4 | "fmt" 5 | "time" 6 | ) 7 | 8 | // RecvOrTimeout attempts to recv over chan c, returning the value. If the 9 | // timeout passes before the recv succeeds, an error is returned. 10 | func RecvOrTimeout[T any](c <-chan T, timeout time.Duration) (*T, error) { 11 | select { 12 | case m := <-c: 13 | return &m, nil 14 | 15 | case <-time.After(timeout): 16 | return nil, fmt.Errorf("timeout hit") 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /lnutils/errors.go: -------------------------------------------------------------------------------- 1 | package lnutils 2 | 3 | import "errors" 4 | 5 | // ErrorAs behaves the same as `errors.As` except there's no need to declare 6 | // the target error as a variable first. 7 | // Instead of writing: 8 | // 9 | // var targetErr *TargetErr 10 | // errors.As(err, &targetErr) 11 | // 12 | // We can write: 13 | // 14 | // lnutils.ErrorAs[*TargetErr](err) 15 | // 16 | // To save us from declaring the target error variable. 17 | func ErrorAs[Target error](err error) bool { 18 | var targetErr Target 19 | 20 | return errors.As(err, &targetErr) 21 | } 22 | -------------------------------------------------------------------------------- /lnutils/fs.go: -------------------------------------------------------------------------------- 1 | package lnutils 2 | 3 | import ( 4 | "errors" 5 | "fmt" 6 | "os" 7 | ) 8 | 9 | // CreateDir creates a directory if it doesn't exist and also handles 10 | // symlink-related errors with user-friendly messages. It creates all necessary 11 | // parent directories with the specified permissions. 12 | func CreateDir(dir string, perm os.FileMode) error { 13 | err := os.MkdirAll(dir, perm) 14 | if err == nil { 15 | return nil 16 | } 17 | 18 | // Show a nicer error message if it's because a symlink 19 | // is linked to a directory that does not exist 20 | // (probably because it's not mounted). 21 | var pathErr *os.PathError 22 | if errors.As(err, &pathErr) && os.IsExist(err) { 23 | link, lerr := os.Readlink(pathErr.Path) 24 | if lerr == nil { 25 | return fmt.Errorf("is symlink %s -> %s "+ 26 | "mounted?", pathErr.Path, link) 27 | } 28 | } 29 | 30 | return fmt.Errorf("failed to create directory '%s': %w", dir, err) 31 | } 32 | -------------------------------------------------------------------------------- /lnutils/memory.go: -------------------------------------------------------------------------------- 1 | package lnutils 2 | 3 | // Ptr returns the pointer of the given value. This is useful in instances 4 | // where a function returns the value, but a pointer is wanted. Without this, 5 | // then an intermediate variable is needed. 6 | func Ptr[T any](v T) *T { 7 | return &v 8 | } 9 | 10 | // ByteArray is a type constraint for type that reduces down to a fixed sized 11 | // array. 12 | type ByteArray interface { 13 | ~[32]byte 14 | } 15 | 16 | // ByteSlice takes a byte array, and returns a slice. This is useful when a 17 | // function returns an array, but a slice is wanted. Without this, then an 18 | // intermediate variable is needed. 19 | func ByteSlice[T ByteArray](v T) []byte { 20 | return v[:] 21 | } 22 | -------------------------------------------------------------------------------- /lnutils/stream.go: -------------------------------------------------------------------------------- 1 | package lnutils 2 | 3 | // Map takes an input slice, and applies the function f to each element, 4 | // yielding a new slice. 5 | func Map[T1, T2 any](s []T1, f func(T1) T2) []T2 { 6 | r := make([]T2, len(s)) 7 | 8 | for i, v := range s { 9 | r[i] = f(v) 10 | } 11 | 12 | return r 13 | } 14 | -------------------------------------------------------------------------------- /lnwallet/btcwallet/btcwallet_integration.go: -------------------------------------------------------------------------------- 1 | //go:build integration || lowscrypt 2 | 3 | package btcwallet 4 | 5 | import ( 6 | "github.com/btcsuite/btcwallet/snacl" 7 | "github.com/btcsuite/btcwallet/waddrmgr" 8 | ) 9 | 10 | func init() { 11 | // Instruct waddrmgr to use the cranked down scrypt parameters when 12 | // creating new wallet encryption keys. This will speed up the itests 13 | // considerably. 14 | fastScrypt := waddrmgr.FastScryptOptions 15 | keyGen := func(passphrase *[]byte, config *waddrmgr.ScryptOptions) ( 16 | *snacl.SecretKey, error) { 17 | 18 | return snacl.NewSecretKey( 19 | passphrase, fastScrypt.N, fastScrypt.R, fastScrypt.P, 20 | ) 21 | } 22 | waddrmgr.SetSecretKeyGen(keyGen) 23 | } 24 | -------------------------------------------------------------------------------- /lnwallet/chainfee/log.go: -------------------------------------------------------------------------------- 1 | package chainfee 2 | 3 | import ( 4 | "github.com/btcsuite/btclog/v2" 5 | "github.com/lightningnetwork/lnd/build" 6 | ) 7 | 8 | // log is a logger that is initialized with no output filters. This means the 9 | // package will not perform any logging by default until the caller requests 10 | // it. 11 | var log btclog.Logger 12 | 13 | // The default amount of logging is none. 14 | func init() { 15 | UseLogger(build.NewSubLogger("CFEE", nil)) 16 | } 17 | 18 | // DisableLog disables all library log output. Logging output is disabled by 19 | // default until UseLogger is called. 20 | func DisableLog() { 21 | UseLogger(btclog.Disabled) 22 | } 23 | 24 | // UseLogger uses a specified Logger to output package logging info. This 25 | // should be used in preference to SetLogWriter if the caller is also using 26 | // btclog. 27 | func UseLogger(logger btclog.Logger) { 28 | log = logger 29 | } 30 | -------------------------------------------------------------------------------- /lnwallet/chainfee/rates_test.go: -------------------------------------------------------------------------------- 1 | package chainfee 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/stretchr/testify/require" 7 | ) 8 | 9 | // TestSatPerVByteConversion checks that the conversion from sat/vb to either 10 | // sat/kw or sat/kvb is correct. 11 | func TestSatPerVByteConversion(t *testing.T) { 12 | t.Parallel() 13 | 14 | // Create a test fee rate of 1 sat/vb. 15 | rate := SatPerVByte(1) 16 | 17 | // 1 sat/vb should be equal to 1000 sat/kvb. 18 | require.Equal(t, SatPerKVByte(1000), rate.FeePerKVByte()) 19 | 20 | // 1 sat/vb should be equal to 250 sat/kw. 21 | require.Equal(t, SatPerKWeight(250), rate.FeePerKWeight()) 22 | } 23 | -------------------------------------------------------------------------------- /lnwallet/chancloser/log.go: -------------------------------------------------------------------------------- 1 | package chancloser 2 | 3 | import ( 4 | "github.com/btcsuite/btclog/v2" 5 | "github.com/lightningnetwork/lnd/build" 6 | ) 7 | 8 | // chancloserLog is a logger that is initialized with the btclog.Disabled 9 | // logger. 10 | var chancloserLog btclog.Logger 11 | 12 | // The default amount of logging is none. 13 | func init() { 14 | UseLogger(build.NewSubLogger("CHCL", nil)) 15 | } 16 | 17 | // DisableLog disables all logging output. 18 | func DisableLog() { 19 | UseLogger(btclog.Disabled) 20 | } 21 | 22 | // UseLogger uses a specified Logger to output package logging info. 23 | func UseLogger(logger btclog.Logger) { 24 | chancloserLog = logger 25 | } 26 | -------------------------------------------------------------------------------- /lnwallet/chanfunding/log.go: -------------------------------------------------------------------------------- 1 | package chanfunding 2 | 3 | import ( 4 | "github.com/btcsuite/btclog/v2" 5 | "github.com/lightningnetwork/lnd/build" 6 | ) 7 | 8 | // log is a logger that is initialized with no output filters. This 9 | // means the package will not perform any logging by default until the caller 10 | // requests it. 11 | var log btclog.Logger 12 | 13 | // The default amount of logging is none. 14 | func init() { 15 | UseLogger(build.NewSubLogger("CHFD", nil)) 16 | } 17 | 18 | // DisableLog disables all library log output. Logging output is disabled 19 | // by default until UseLogger is called. 20 | func DisableLog() { 21 | UseLogger(btclog.Disabled) 22 | } 23 | 24 | // UseLogger uses a specified Logger to output package logging info. 25 | // This should be used in preference to SetLogWriter if the caller is also 26 | // using btclog. 27 | func UseLogger(logger btclog.Logger) { 28 | log = logger 29 | } 30 | -------------------------------------------------------------------------------- /lnwallet/rebroadcaster.go: -------------------------------------------------------------------------------- 1 | package lnwallet 2 | 3 | import ( 4 | "github.com/btcsuite/btcd/chaincfg/chainhash" 5 | "github.com/btcsuite/btcd/wire" 6 | ) 7 | 8 | // Rebroadcaster is an abstract rebroadcaster instance that'll continually 9 | // rebroadcast transactions in the background until they're confirmed. 10 | type Rebroadcaster interface { 11 | // Start launches all goroutines the rebroadcaster needs to operate. 12 | Start() error 13 | 14 | // Started returns true if the broadcaster is already active. 15 | Started() bool 16 | 17 | // Stop terminates the rebroadcaster and all goroutines it spawned. 18 | Stop() 19 | 20 | // Broadcast enqueues a transaction to be rebroadcast until it's been 21 | // confirmed. 22 | Broadcast(tx *wire.MsgTx) error 23 | 24 | // MarkAsConfirmed marks a transaction as confirmed, so it won't be 25 | // rebroadcast. 26 | MarkAsConfirmed(txid chainhash.Hash) 27 | } 28 | -------------------------------------------------------------------------------- /lnwallet/rpcwallet/healthcheck.go: -------------------------------------------------------------------------------- 1 | package rpcwallet 2 | 3 | import ( 4 | "fmt" 5 | "time" 6 | 7 | "github.com/lightningnetwork/lnd/lncfg" 8 | ) 9 | 10 | // HealthCheck returns a health check function for the given remote signing 11 | // configuration. 12 | func HealthCheck(cfg *lncfg.RemoteSigner, timeout time.Duration) func() error { 13 | return func() error { 14 | conn, err := connectRPC( 15 | cfg.RPCHost, cfg.TLSCertPath, cfg.MacaroonPath, timeout, 16 | ) 17 | if err != nil { 18 | return fmt.Errorf("error connecting to the remote "+ 19 | "signing node through RPC: %v", err) 20 | } 21 | 22 | defer func() { 23 | err = conn.Close() 24 | if err != nil { 25 | log.Warnf("Failed to close health check "+ 26 | "connection to remote signing node: %v", 27 | err) 28 | } 29 | }() 30 | 31 | return nil 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /lnwallet/test/bitcoind/bitcoind_test.go: -------------------------------------------------------------------------------- 1 | package bitcoind_test 2 | 3 | import ( 4 | "testing" 5 | 6 | lnwallettest "github.com/lightningnetwork/lnd/lnwallet/test" 7 | ) 8 | 9 | // TestLightningWalletBitcoindZMQ tests LightningWallet powered by bitcoind, 10 | // using its ZMQ interface, against our suite of interface tests. 11 | func TestLightningWalletBitcoindZMQ(t *testing.T) { 12 | lnwallettest.TestLightningWallet(t, "bitcoind") 13 | } 14 | 15 | // TestLightningWalletBitcoindRPCPolling tests LightningWallet powered by 16 | // bitcoind, using its RPC interface, against our suite of interface tests. 17 | func TestLightningWalletBitcoindRPCPolling(t *testing.T) { 18 | lnwallettest.TestLightningWallet(t, "bitcoind-rpc-polling") 19 | } 20 | -------------------------------------------------------------------------------- /lnwallet/test/btcd/btcd_test.go: -------------------------------------------------------------------------------- 1 | package btcd_test 2 | 3 | import ( 4 | "testing" 5 | 6 | lnwallettest "github.com/lightningnetwork/lnd/lnwallet/test" 7 | ) 8 | 9 | // TestLightningWallet tests LightningWallet powered by btcd against our suite 10 | // of interface tests. 11 | func TestLightningWallet(t *testing.T) { 12 | lnwallettest.TestLightningWallet(t, "btcd") 13 | } 14 | -------------------------------------------------------------------------------- /lnwallet/test/neutrino/neutrino_test.go: -------------------------------------------------------------------------------- 1 | package neutrino_test 2 | 3 | import ( 4 | "testing" 5 | 6 | lnwallettest "github.com/lightningnetwork/lnd/lnwallet/test" 7 | ) 8 | 9 | // TestLightningWallet tests LightningWallet powered by neutrino against our 10 | // suite of interface tests. 11 | func TestLightningWallet(t *testing.T) { 12 | lnwallettest.TestLightningWallet(t, "neutrino") 13 | } 14 | -------------------------------------------------------------------------------- /lnwire/README.md: -------------------------------------------------------------------------------- 1 | lnwire 2 | ====== 3 | 4 | [![Build Status](http://img.shields.io/travis/lightningnetwork/lnd.svg)](https://travis-ci.org/lightningnetwork/lnd) 5 | [![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/lightningnetwork/lnd/blob/master/LICENSE) 6 | [![GoDoc](https://img.shields.io/badge/godoc-reference-blue.svg)](http://godoc.org/github.com/lightningnetwork/lnd/lnwire) 7 | 8 | The lnwire package implements the Lightning Network wire protocol. 9 | 10 | This package has intentionally been designed so it can be used as a standalone 11 | package for any projects needing to interface with lightning peers at the wire 12 | protocol level. 13 | 14 | ## Installation and Updating 15 | 16 | ```shell 17 | $ go get -u github.com/lightningnetwork/lnd/lnwire 18 | ``` 19 | -------------------------------------------------------------------------------- /lnwire/channel_type_test.go: -------------------------------------------------------------------------------- 1 | package lnwire 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/stretchr/testify/require" 7 | ) 8 | 9 | // TestChannelTypeEncodeDecode tests that we're able to properly encode and 10 | // decode channel types within TLV streams. 11 | func TestChannelTypeEncodeDecode(t *testing.T) { 12 | t.Parallel() 13 | 14 | chanType := ChannelType(*NewRawFeatureVector( 15 | StaticRemoteKeyRequired, 16 | AnchorsZeroFeeHtlcTxRequired, 17 | )) 18 | 19 | var extraData ExtraOpaqueData 20 | require.NoError(t, extraData.PackRecords(&chanType)) 21 | 22 | var chanType2 ChannelType 23 | tlvs, err := extraData.ExtractRecords(&chanType2) 24 | require.NoError(t, err) 25 | 26 | require.Contains(t, tlvs, ChannelTypeRecordType) 27 | require.Equal(t, chanType, chanType2) 28 | } 29 | -------------------------------------------------------------------------------- /lnwire/typed_delivery_addr_test.go: -------------------------------------------------------------------------------- 1 | package lnwire 2 | 3 | import ( 4 | "bytes" 5 | "testing" 6 | ) 7 | 8 | // TestDeliveryAddressEncodeDecode tests that we're able to properly 9 | // encode and decode delivery addresses within TLV streams. 10 | func TestDeliveryAddressEncodeDecode(t *testing.T) { 11 | t.Parallel() 12 | 13 | addr := DeliveryAddress( 14 | bytes.Repeat([]byte("a"), deliveryAddressMaxSize), 15 | ) 16 | 17 | var extraData ExtraOpaqueData 18 | err := extraData.PackRecords(&addr) 19 | if err != nil { 20 | t.Fatal(err) 21 | } 22 | 23 | var addr2 DeliveryAddress 24 | tlvs, err := extraData.ExtractRecords(&addr2) 25 | if err != nil { 26 | t.Fatal(err) 27 | } 28 | 29 | if _, ok := tlvs[DeliveryAddrType]; !ok { 30 | t.Fatalf("DeliveryAddrType not found in records") 31 | } 32 | 33 | if !bytes.Equal(addr, addr2) { 34 | t.Fatalf("addr mismatch: expected %x, got %x", addr[:], 35 | addr2[:]) 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /lnwire/typed_fee_test.go: -------------------------------------------------------------------------------- 1 | package lnwire 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/stretchr/testify/require" 7 | ) 8 | 9 | func TestTypedFee(t *testing.T) { 10 | t.Parallel() 11 | 12 | t.Run("positive", func(t *testing.T) { 13 | t.Parallel() 14 | 15 | testTypedFee(t, Fee{ 16 | BaseFee: 10, 17 | FeeRate: 20, 18 | }) 19 | }) 20 | 21 | t.Run("negative", func(t *testing.T) { 22 | t.Parallel() 23 | 24 | testTypedFee(t, Fee{ 25 | BaseFee: -10, 26 | FeeRate: -20, 27 | }) 28 | }) 29 | } 30 | 31 | func testTypedFee(t *testing.T, fee Fee) { //nolint: thelper 32 | var eob ExtraOpaqueData 33 | require.NoError(t, eob.PackRecords(&fee)) 34 | 35 | var extractedFee Fee 36 | _, err := eob.ExtractRecords(&extractedFee) 37 | require.NoError(t, err) 38 | 39 | require.Equal(t, fee, extractedFee) 40 | } 41 | -------------------------------------------------------------------------------- /lnwire/typed_lease_expiry_test.go: -------------------------------------------------------------------------------- 1 | package lnwire 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/stretchr/testify/require" 7 | ) 8 | 9 | // TestChannelTypeEncodeDecode tests that we're able to properly encode and 10 | // decode channel types within TLV streams. 11 | func TestLeaseExpiryEncodeDecode(t *testing.T) { 12 | t.Parallel() 13 | 14 | leaseExpiry := LeaseExpiry(1337) 15 | 16 | var extraData ExtraOpaqueData 17 | require.NoError(t, extraData.PackRecords(&leaseExpiry)) 18 | 19 | var leaseExpiry2 LeaseExpiry 20 | tlvs, err := extraData.ExtractRecords(&leaseExpiry2) 21 | require.NoError(t, err) 22 | 23 | require.Contains(t, tlvs, LeaseExpiryRecordType) 24 | require.Equal(t, leaseExpiry, leaseExpiry2) 25 | } 26 | -------------------------------------------------------------------------------- /logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lightningnetwork/lnd/5a036a8fcd1ee2ffd8e58290782be68399dcca86/logo.png -------------------------------------------------------------------------------- /macaroons/security.go: -------------------------------------------------------------------------------- 1 | package macaroons 2 | 3 | import "github.com/btcsuite/btcwallet/snacl" 4 | 5 | var ( 6 | // Below are the default scrypt parameters that are used when creating 7 | // the encryption key for the macaroon database with snacl.NewSecretKey. 8 | scryptN = snacl.DefaultN 9 | scryptR = snacl.DefaultR 10 | scryptP = snacl.DefaultP 11 | ) 12 | -------------------------------------------------------------------------------- /macaroons/security_integration.go: -------------------------------------------------------------------------------- 1 | //go:build integration 2 | 3 | package macaroons 4 | 5 | import "github.com/btcsuite/btcwallet/waddrmgr" 6 | 7 | func init() { 8 | // Below are the reduced scrypt parameters that are used when creating 9 | // the encryption key for the macaroon database with snacl.NewSecretKey. 10 | // We use very low values for our itest/rpctest to speed things up. 11 | scryptN = waddrmgr.FastScryptOptions.N 12 | scryptR = waddrmgr.FastScryptOptions.R 13 | scryptP = waddrmgr.FastScryptOptions.P 14 | } 15 | -------------------------------------------------------------------------------- /macaroons/security_test.go: -------------------------------------------------------------------------------- 1 | package macaroons 2 | 3 | import "github.com/btcsuite/btcwallet/waddrmgr" 4 | 5 | func init() { 6 | // Below are the reduced scrypt parameters that are used when creating 7 | // the encryption key for the macaroon database with snacl.NewSecretKey. 8 | // We use very low values for our itest/rpctest to speed things up. 9 | scryptN = waddrmgr.FastScryptOptions.N 10 | scryptR = waddrmgr.FastScryptOptions.R 11 | scryptP = waddrmgr.FastScryptOptions.P 12 | } 13 | -------------------------------------------------------------------------------- /make/fuzz_flags.mk: -------------------------------------------------------------------------------- 1 | FUZZPKG = brontide lnwire watchtower/wtwire zpay32 2 | FUZZ_TEST_RUN_TIME = 30s 3 | FUZZ_NUM_PROCESSES = 4 4 | 5 | # If specific package is being fuzzed, construct the full name of the 6 | # subpackage. 7 | ifneq ($(pkg),) 8 | FUZZPKG := $(pkg) 9 | endif 10 | 11 | # The default run time per fuzz test is pretty low and normally will be 12 | # overwritten by a user depending on the time they have available. 13 | ifneq ($(fuzztime),) 14 | FUZZ_TEST_RUN_TIME := $(fuzztime) 15 | endif 16 | 17 | # Overwrites the number of parallel processes. Should be set to the number of 18 | # processor cores in a system. 19 | ifneq ($(parallel),) 20 | FUZZ_NUM_PROCESSES := $(parallel) 21 | endif 22 | -------------------------------------------------------------------------------- /mobile/docs/proto_folder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lightningnetwork/lnd/5a036a8fcd1ee2ffd8e58290782be68399dcca86/mobile/docs/proto_folder.png -------------------------------------------------------------------------------- /mobile/docs/separate_gradle_module.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lightningnetwork/lnd/5a036a8fcd1ee2ffd8e58290782be68399dcca86/mobile/docs/separate_gradle_module.png -------------------------------------------------------------------------------- /mobile/sample_lnd.conf: -------------------------------------------------------------------------------- 1 | [Application Options] 2 | debuglevel=info 3 | maxbackoff=2s 4 | nolisten=1 5 | norest=1 6 | tlsdisableautofill=1 7 | 8 | [Routing] 9 | routing.assumechanvalid=1 10 | 11 | [Bitcoin] 12 | bitcoin.active=1 13 | bitcoin.testnet=1 14 | bitcoin.node=neutrino 15 | -------------------------------------------------------------------------------- /monitoring/log.go: -------------------------------------------------------------------------------- 1 | package monitoring 2 | 3 | import ( 4 | "github.com/btcsuite/btclog/v2" 5 | "github.com/lightningnetwork/lnd/build" 6 | ) 7 | 8 | // log is a logger that is initialized with no output filters. This means the 9 | // package will not perform any logging by default until the caller requests 10 | // it. 11 | var log btclog.Logger 12 | 13 | // The default amount of logging is none. 14 | func init() { 15 | UseLogger(build.NewSubLogger("PROM", nil)) 16 | } 17 | 18 | // DisableLog disables all library log output. Logging output is disabled by 19 | // default until UseLogger is called. 20 | func DisableLog() { 21 | UseLogger(btclog.Disabled) 22 | } 23 | 24 | // UseLogger uses a specified Logger to output package logging info. This 25 | // should be used in preference to SetLogWriter if the caller is also using 26 | // btclog. 27 | func UseLogger(logger btclog.Logger) { 28 | log = logger 29 | } 30 | -------------------------------------------------------------------------------- /monitoring/monitoring_off.go: -------------------------------------------------------------------------------- 1 | //go:build !monitoring 2 | // +build !monitoring 3 | 4 | package monitoring 5 | 6 | import ( 7 | "fmt" 8 | 9 | "github.com/lightningnetwork/lnd/lncfg" 10 | "google.golang.org/grpc" 11 | ) 12 | 13 | // GetPromInterceptors returns the set of interceptors for Prometheus 14 | // monitoring if monitoring is enabled, else empty slices. Monitoring is 15 | // currently disabled. 16 | func GetPromInterceptors() ([]grpc.UnaryServerInterceptor, []grpc.StreamServerInterceptor) { 17 | return []grpc.UnaryServerInterceptor{}, []grpc.StreamServerInterceptor{} 18 | } 19 | 20 | // ExportPrometheusMetrics is required for lnd to compile so that Prometheus 21 | // metric exporting can be hidden behind a build tag. 22 | func ExportPrometheusMetrics(_ *grpc.Server, _ lncfg.Prometheus) error { 23 | return fmt.Errorf("lnd must be built with the monitoring tag to " + 24 | "enable exporting Prometheus metrics") 25 | } 26 | -------------------------------------------------------------------------------- /msgmux/log.go: -------------------------------------------------------------------------------- 1 | package msgmux 2 | 3 | import ( 4 | "github.com/btcsuite/btclog/v2" 5 | "github.com/lightningnetwork/lnd/build" 6 | ) 7 | 8 | // Subsystem defines the logging code for this subsystem. 9 | const Subsystem = "MSGX" 10 | 11 | // log is a logger that is initialized with no output filters. This 12 | // means the package will not perform any logging by default until the caller 13 | // requests it. 14 | var log btclog.Logger 15 | 16 | // The default amount of logging is none. 17 | func init() { 18 | UseLogger(build.NewSubLogger(Subsystem, nil)) 19 | } 20 | 21 | // DisableLog disables all library log output. Logging output is disabled 22 | // by default until UseLogger is called. 23 | func DisableLog() { 24 | UseLogger(btclog.Disabled) 25 | } 26 | 27 | // UseLogger uses a specified Logger to output package logging info. 28 | // This should be used in preference to SetLogWriter if the caller is also 29 | // using btclog. 30 | func UseLogger(logger btclog.Logger) { 31 | log = logger 32 | } 33 | -------------------------------------------------------------------------------- /netann/interface.go: -------------------------------------------------------------------------------- 1 | package netann 2 | 3 | import ( 4 | "github.com/btcsuite/btcd/wire" 5 | "github.com/lightningnetwork/lnd/channeldb" 6 | "github.com/lightningnetwork/lnd/graph/db/models" 7 | ) 8 | 9 | // DB abstracts the required database functionality needed by the 10 | // ChanStatusManager. 11 | type DB interface { 12 | // FetchAllOpenChannels returns a slice of all open channels known to 13 | // the daemon. This may include private or pending channels. 14 | FetchAllOpenChannels() ([]*channeldb.OpenChannel, error) 15 | } 16 | 17 | // ChannelGraph abstracts the required channel graph queries used by the 18 | // ChanStatusManager. 19 | type ChannelGraph interface { 20 | // FetchChannelEdgesByOutpoint returns the channel edge info and most 21 | // recent channel edge policies for a given outpoint. 22 | FetchChannelEdgesByOutpoint(*wire.OutPoint) (*models.ChannelEdgeInfo, 23 | *models.ChannelEdgePolicy, *models.ChannelEdgePolicy, error) 24 | } 25 | -------------------------------------------------------------------------------- /netann/log.go: -------------------------------------------------------------------------------- 1 | package netann 2 | 3 | import ( 4 | "github.com/btcsuite/btclog/v2" 5 | "github.com/lightningnetwork/lnd/build" 6 | ) 7 | 8 | // log is a logger that is initialized with no output filters. This means the 9 | // package will not perform any logging by default until the caller requests 10 | // it. 11 | var log btclog.Logger 12 | 13 | // The default amount of logging is none. 14 | func init() { 15 | UseLogger(build.NewSubLogger("NANN", nil)) 16 | } 17 | 18 | // DisableLog disables all library log output. Logging output is disabled by 19 | // by default until UseLogger is called. 20 | func DisableLog() { 21 | UseLogger(btclog.Disabled) 22 | } 23 | 24 | // UseLogger uses a specified Logger to output package logging info. This 25 | // should be used in preference to SetLogWriter if the caller is also using 26 | // btclog. 27 | func UseLogger(logger btclog.Logger) { 28 | log = logger 29 | } 30 | -------------------------------------------------------------------------------- /peer/log.go: -------------------------------------------------------------------------------- 1 | package peer 2 | 3 | import ( 4 | "github.com/btcsuite/btclog/v2" 5 | "github.com/lightningnetwork/lnd/build" 6 | ) 7 | 8 | // peerLog is a logger that is initialized with the btclog.Disabled logger. 9 | var peerLog btclog.Logger 10 | 11 | // The default amount of logging is none. 12 | func init() { 13 | UseLogger(build.NewSubLogger("PEER", nil)) 14 | } 15 | 16 | // DisableLog disables all logging output. 17 | func DisableLog() { 18 | UseLogger(btclog.Disabled) 19 | } 20 | 21 | // UseLogger uses a specified Logger to output package logging info. 22 | func UseLogger(logger btclog.Logger) { 23 | peerLog = logger 24 | } 25 | -------------------------------------------------------------------------------- /peer/setup_test.go: -------------------------------------------------------------------------------- 1 | package peer 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/lightningnetwork/lnd/kvdb" 7 | ) 8 | 9 | func TestMain(m *testing.M) { 10 | kvdb.RunTests(m) 11 | } 12 | -------------------------------------------------------------------------------- /peernotifier/log.go: -------------------------------------------------------------------------------- 1 | package peernotifier 2 | 3 | import ( 4 | "github.com/btcsuite/btclog/v2" 5 | "github.com/lightningnetwork/lnd/build" 6 | ) 7 | 8 | // log is a logger that is initialized with no output filters. This 9 | // means the package will not perform any logging by default until the caller 10 | // requests it. 11 | var log btclog.Logger 12 | 13 | // The default amount of logging is none. 14 | func init() { 15 | UseLogger(build.NewSubLogger("PRNF", nil)) 16 | } 17 | 18 | // DisableLog disables all library log output. Logging output is disabled 19 | // by default until UseLogger is called. 20 | func DisableLog() { 21 | UseLogger(btclog.Disabled) 22 | } 23 | 24 | // UseLogger uses a specified Logger to output package logging info. 25 | // This should be used in preference to SetLogWriter if the caller is also 26 | // using btclog. 27 | func UseLogger(logger btclog.Logger) { 28 | log = logger 29 | } 30 | -------------------------------------------------------------------------------- /protofsm/log.go: -------------------------------------------------------------------------------- 1 | package protofsm 2 | 3 | import ( 4 | "github.com/btcsuite/btclog/v2" 5 | "github.com/lightningnetwork/lnd/build" 6 | ) 7 | 8 | // log is a logger that is initialized with no output filters. This 9 | // means the package will not perform any logging by default until the caller 10 | // requests it. 11 | var log btclog.Logger 12 | 13 | // The default amount of logging is none. 14 | func init() { 15 | UseLogger(build.NewSubLogger("PFSM", nil)) 16 | } 17 | 18 | // DisableLog disables all library log output. Logging output is disabled 19 | // by default until UseLogger is called. 20 | func DisableLog() { 21 | UseLogger(btclog.Disabled) 22 | } 23 | 24 | // UseLogger uses a specified Logger to output package logging info. 25 | // This should be used in preference to SetLogWriter if the caller is also 26 | // using btclog. 27 | func UseLogger(logger btclog.Logger) { 28 | log = logger 29 | } 30 | -------------------------------------------------------------------------------- /protofsm/msg_mapper.go: -------------------------------------------------------------------------------- 1 | package protofsm 2 | 3 | import ( 4 | "github.com/lightningnetwork/lnd/fn/v2" 5 | "github.com/lightningnetwork/lnd/msgmux" 6 | ) 7 | 8 | // MsgMapper is used to map incoming wire messages into a FSM event. This is 9 | // useful to decouple the translation of an outside or wire message into an 10 | // event type that can be understood by the FSM. 11 | type MsgMapper[Event any] interface { 12 | // MapMsg maps a wire message into a FSM event. If the message is not 13 | // mappable, then an None is returned. 14 | MapMsg(msg msgmux.PeerMsg) fn.Option[Event] 15 | } 16 | -------------------------------------------------------------------------------- /queue/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/lightningnetwork/lnd/queue 2 | 3 | require github.com/lightningnetwork/lnd/ticker v1.0.0 4 | 5 | replace github.com/lightningnetwork/lnd/ticker v1.0.0 => ../ticker 6 | 7 | go 1.19 8 | -------------------------------------------------------------------------------- /queue/go.sum: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lightningnetwork/lnd/5a036a8fcd1ee2ffd8e58290782be68399dcca86/queue/go.sum -------------------------------------------------------------------------------- /record/custom_records.go: -------------------------------------------------------------------------------- 1 | package record 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | const ( 8 | // CustomTypeStart is the start of the custom tlv type range as defined 9 | // in BOLT 01. 10 | CustomTypeStart = 65536 11 | ) 12 | 13 | // CustomSet stores a set of custom key/value pairs. 14 | type CustomSet map[uint64][]byte 15 | 16 | // Validate checks that all custom records are in the custom type range. 17 | func (c CustomSet) Validate() error { 18 | for key := range c { 19 | if key < CustomTypeStart { 20 | return fmt.Errorf("no custom records with types "+ 21 | "below %v allowed", CustomTypeStart) 22 | } 23 | } 24 | 25 | return nil 26 | } 27 | 28 | // IsKeysend checks if the custom records contain the key send type. 29 | func (c CustomSet) IsKeysend() bool { 30 | return c[KeySendType] != nil 31 | } 32 | -------------------------------------------------------------------------------- /record/experimental.go: -------------------------------------------------------------------------------- 1 | package record 2 | 3 | const ( 4 | // KeySendType is the custom record identifier for keysend preimages. 5 | KeySendType uint64 = 5482373484 6 | ) 7 | -------------------------------------------------------------------------------- /routing/README.md: -------------------------------------------------------------------------------- 1 | routing 2 | ======= 3 | 4 | [![Build Status](http://img.shields.io/travis/lightningnetwork/lnd.svg)](https://travis-ci.org/lightningnetwork/lnd) 5 | [![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/lightningnetwork/lnd/blob/master/LICENSE) 6 | [![GoDoc](https://img.shields.io/badge/godoc-reference-blue.svg)](http://godoc.org/github.com/lightningnetwork/lnd/routing) 7 | 8 | The routing package implements authentication+validation of channel 9 | announcements, pruning of the channel graph, path finding within the network, 10 | sending outgoing payments into the network and synchronizing new peers to our 11 | channel graph state. 12 | 13 | ## Installation and Updating 14 | 15 | ```shell 16 | $ go get -u github.com/lightningnetwork/lnd/routing 17 | ``` 18 | -------------------------------------------------------------------------------- /routing/blindedpath/log.go: -------------------------------------------------------------------------------- 1 | package blindedpath 2 | 3 | import ( 4 | "github.com/btcsuite/btclog/v2" 5 | "github.com/lightningnetwork/lnd/build" 6 | ) 7 | 8 | // log is a logger that is initialized with no output filters. This means the 9 | // package will not perform any logging by default until the caller requests 10 | // it. 11 | var log btclog.Logger 12 | 13 | const Subsystem = "BLPT" 14 | 15 | // The default amount of logging is none. 16 | func init() { 17 | UseLogger(build.NewSubLogger(Subsystem, nil)) 18 | } 19 | 20 | // DisableLog disables all library log output. Logging output is disabled by 21 | // default until UseLogger is called. 22 | func DisableLog() { 23 | UseLogger(btclog.Disabled) 24 | } 25 | 26 | // UseLogger uses a specified Logger to output package logging info. This 27 | // should be used in preference to SetLogWriter if the caller is also using 28 | // btclog. 29 | func UseLogger(logger btclog.Logger) { 30 | log = logger 31 | } 32 | -------------------------------------------------------------------------------- /routing/chainview/log.go: -------------------------------------------------------------------------------- 1 | package chainview 2 | 3 | import ( 4 | "github.com/btcsuite/btclog/v2" 5 | "github.com/lightningnetwork/lnd/build" 6 | ) 7 | 8 | // log is a logger that is initialized with no output filters. This 9 | // means the package will not perform any logging by default until the caller 10 | // requests it. 11 | var log btclog.Logger 12 | 13 | // The default amount of logging is none. 14 | func init() { 15 | UseLogger(build.NewSubLogger("CRTR", nil)) 16 | } 17 | 18 | // DisableLog disables all library log output. Logging output is disabled 19 | // by default until either UseLogger or SetLogWriter are called. 20 | func DisableLog() { 21 | UseLogger(btclog.Disabled) 22 | } 23 | 24 | // UseLogger uses a specified Logger to output package logging info. 25 | // This should be used in preference to SetLogWriter if the caller is also 26 | // using btclog. 27 | func UseLogger(logger btclog.Logger) { 28 | log = logger 29 | } 30 | -------------------------------------------------------------------------------- /routing/localchans/log.go: -------------------------------------------------------------------------------- 1 | package localchans 2 | 3 | import ( 4 | "github.com/btcsuite/btclog/v2" 5 | "github.com/lightningnetwork/lnd/build" 6 | ) 7 | 8 | // log is a logger that is initialized with no output filters. This means the 9 | // package will not perform any logging by default until the caller requests 10 | // it. 11 | var log btclog.Logger 12 | 13 | const Subsystem = "LCHN" 14 | 15 | // The default amount of logging is none. 16 | func init() { 17 | UseLogger(build.NewSubLogger(Subsystem, nil)) 18 | } 19 | 20 | // DisableLog disables all library log output. Logging output is disabled by 21 | // default until UseLogger is called. 22 | func DisableLog() { 23 | UseLogger(btclog.Disabled) 24 | } 25 | 26 | // UseLogger uses a specified Logger to output package logging info. This 27 | // should be used in preference to SetLogWriter if the caller is also using 28 | // btclog. 29 | func UseLogger(logger btclog.Logger) { 30 | log = logger 31 | } 32 | -------------------------------------------------------------------------------- /routing/nodepair.go: -------------------------------------------------------------------------------- 1 | package routing 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/lightningnetwork/lnd/routing/route" 7 | ) 8 | 9 | // DirectedNodePair stores a directed pair of nodes. 10 | type DirectedNodePair struct { 11 | From, To route.Vertex 12 | } 13 | 14 | // NewDirectedNodePair instantiates a new DirectedNodePair struct. 15 | func NewDirectedNodePair(from, to route.Vertex) DirectedNodePair { 16 | return DirectedNodePair{ 17 | From: from, 18 | To: to, 19 | } 20 | } 21 | 22 | // String converts a node pair to its human readable representation. 23 | func (d DirectedNodePair) String() string { 24 | return fmt.Sprintf("%v -> %v", d.From, d.To) 25 | } 26 | 27 | // Reverse returns a reversed copy of the pair. 28 | func (d DirectedNodePair) Reverse() DirectedNodePair { 29 | return DirectedNodePair{From: d.To, To: d.From} 30 | } 31 | -------------------------------------------------------------------------------- /routing/setup_test.go: -------------------------------------------------------------------------------- 1 | package routing 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/lightningnetwork/lnd/kvdb" 7 | ) 8 | 9 | func TestMain(m *testing.M) { 10 | kvdb.RunTests(m) 11 | } 12 | -------------------------------------------------------------------------------- /rpcperms/log.go: -------------------------------------------------------------------------------- 1 | package rpcperms 2 | 3 | import ( 4 | "github.com/btcsuite/btclog/v2" 5 | "github.com/lightningnetwork/lnd/build" 6 | ) 7 | 8 | // Subsystem defines the logging code for this subsystem. 9 | const Subsystem = "RPCP" 10 | 11 | // log is a logger that is initialized with no output filters. This 12 | // means the package will not perform any logging by default until the caller 13 | // requests it. 14 | var log btclog.Logger 15 | 16 | // The default amount of logging is none. 17 | func init() { 18 | UseLogger(build.NewSubLogger(Subsystem, nil)) 19 | } 20 | 21 | // DisableLog disables all library log output. Logging output is disabled 22 | // by default until UseLogger is called. 23 | func DisableLog() { 24 | UseLogger(btclog.Disabled) 25 | } 26 | 27 | // UseLogger uses a specified Logger to output package logging info. 28 | // This should be used in preference to SetLogWriter if the caller is also 29 | // using btclog. 30 | func UseLogger(logger btclog.Logger) { 31 | log = logger 32 | } 33 | -------------------------------------------------------------------------------- /scripts/bw-compatibility-test/.env: -------------------------------------------------------------------------------- 1 | BITCOIND_VERSION=26 2 | LND_LATEST_VERSION=v0.18.5-beta 3 | TIMEOUT=15 4 | -------------------------------------------------------------------------------- /scripts/bw-compatibility-test/execute.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # The execute.sh file can be used to call any helper functions directly 4 | # from the command line. For example: 5 | # $ ./execute.sh compose-up 6 | 7 | # DIR is set to the directory of this script. 8 | DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" 9 | 10 | source "$DIR/.env" 11 | source "$DIR/compose.sh" 12 | source "$DIR/network.sh" 13 | 14 | CMD=$1 15 | shift 16 | $CMD "$@" -------------------------------------------------------------------------------- /scripts/check-commit.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | set -x 4 | echo Testing $(git log -1 --oneline) 5 | make unit pkg=... case=_NONE_ 6 | -------------------------------------------------------------------------------- /scripts/check-each-commit.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | if [[ "$1" = "" ]]; then 3 | echo "USAGE: $0 remote/head_branch" 4 | echo "eg $0 upstream/master" 5 | exit 1 6 | fi 7 | 8 | set -e 9 | set -x 10 | 11 | if [[ "$(git log --pretty="%H %D" | grep "^[0-9a-f]*.* $1")" = "" ]]; then 12 | echo "It seems like the current checked-out commit is not based on $1" 13 | exit 1 14 | fi 15 | git rebase --exec scripts/check-commit.sh $1 16 | -------------------------------------------------------------------------------- /scripts/check-rest-annotations.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | for proto in $(find . -name "*.proto"); do 4 | for rpc in $(awk '/ rpc /{print $2}' "$proto"); do 5 | yaml=${proto%%.proto}.yaml 6 | if ! grep -q "$rpc" "$yaml"; then 7 | echo "RPC $rpc not added to $yaml file" 8 | exit 1 9 | fi 10 | done 11 | done 12 | -------------------------------------------------------------------------------- /scripts/gen_man_pages.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Usage: ./gen_man_pages.sh DESTDIR PREFIX 4 | 5 | # Check if lncli is installed. 6 | function check_lncli_installed() { 7 | if [[ ! $(command -v lncli) ]] 8 | then 9 | echo "lncli could not be found. Please install lncli before running this script." 10 | exit 1 11 | fi 12 | } 13 | 14 | DESTDIR="$1" 15 | PREFIX="$2" 16 | FULLPATH="$DESTDIR$PREFIX" 17 | 18 | check_lncli_installed 19 | 20 | # Ignore warnings regarding HTMLBlock detection in go-md2man package 21 | # since using "<...>" is part of our docs. 22 | lncli generatemanpage 2>&1 | grep -v "go-md2man does not handle node type HTMLSpan" || true 23 | 24 | mkdir -p "$FULLPATH/share/man/man1" 25 | 26 | echo "Installing man pages to $FULLPATH/share/man/man1." 27 | install -m 644 lnd.1 "$FULLPATH/share/man/man1/lnd.1" 28 | install -m 644 lncli.1 "$FULLPATH/share/man/man1/lncli.1" 29 | 30 | # Remove lncli.1 and lnd.1 artifacts from the current working directory. 31 | rm -f lncli.1 lnd.1 32 | -------------------------------------------------------------------------------- /scripts/install_bitcoind.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -ev 4 | 5 | BITCOIND_VERSION=$1 6 | 7 | # Useful for testing RCs: e.g. TAG_SUFFIX=.0rc1, DIR_SUFFIX=.0rc1 8 | TAG_SUFFIX= 9 | DIR_SUFFIX=.0 10 | 11 | # Useful for testing against an image pushed to a different Docker repo. 12 | REPO=lightninglabs/bitcoin-core 13 | 14 | if [ -z "$BITCOIND_VERSION" ]; then 15 | echo "Must specify a version of bitcoind to install." 16 | echo "Usage: install_bitcoind.sh " 17 | exit 1 18 | fi 19 | 20 | docker pull ${REPO}:${BITCOIND_VERSION}${TAG_SUFFIX} 21 | CONTAINER_ID=$(docker create ${REPO}:${BITCOIND_VERSION}${TAG_SUFFIX}) 22 | sudo docker cp $CONTAINER_ID:/opt/bitcoin-${BITCOIND_VERSION}${DIR_SUFFIX}/bin/bitcoind /usr/local/bin/bitcoind 23 | docker rm $CONTAINER_ID 24 | -------------------------------------------------------------------------------- /scripts/keys/README.md: -------------------------------------------------------------------------------- 1 | # Release verification keys 2 | 3 | This directory contains all keys that are currently signing `lnd` releases. 4 | 5 | The name of the file must match exactly the suffix that user is going to use 6 | when signing a release. 7 | For example, if the key is called `eugene_.asc` then that user must upload a 8 | signature file called `manifest-eugene_-v0.xx.yy-beta.sig`, otherwise the 9 | verification will fail. See [the release 10 | documentation](../../docs/release.md#signing-an-existing-manifest-file) for 11 | details on how to create the signature. 12 | 13 | In addition to adding the key file here as a `.asc` file the 14 | `scripts/verify-install.sh` file must also be updated with the key ID and the 15 | reference to the key file. 16 | -------------------------------------------------------------------------------- /scripts/keys/ViktorTigerstrom.asc: -------------------------------------------------------------------------------- 1 | -----BEGIN PGP PUBLIC KEY BLOCK----- 2 | 3 | mDMEZH8cbRYJKwYBBAHaRw8BAQdAkitV+X9eSLEP4gG8hDRxGbQjGFF9LQAz80rx 4 | jpsbCG+0KlZpa3RvciBUaWdlcnN0csO2bSA8dnRpZ2Vyc3Ryb21AZ21haWwuY29t 5 | PoiZBBMWCgBBFiEEGH9q3ZOuOwzzNapquYRXCYBoTcwFAmR/HG0CGwMFCQPCZwAF 6 | CwkIBwICIgIGFQoJCAsCBBYCAwECHgcCF4AACgkQuYRXCYBoTcyk2wEAz756kuHK 7 | 0S6DKt3DkEE5sWChcwPzPF+ZLjppH8Xz+H0BAJCXbEYSZ/T0DB3VjDa3zmQAgvN3 8 | NNxRP8cUfZ+wK+cDuDgEZH8cbRIKKwYBBAGXVQEFAQEHQOWQjkKzCmUA4D89NxPn 9 | 4Ek156kkaIouIevx+fzKW/FFAwEIB4h+BBgWCgAmFiEEGH9q3ZOuOwzzNapquYRX 10 | CYBoTcwFAmR/HG0CGwwFCQPCZwAACgkQuYRXCYBoTcxJ0AEAnKab3Q9GtN2VC2MM 11 | jUPhr+B05Arnk8BYqiqEzRVHlK4BANzpbLmkuBO6RG1237d122yX00z9RAzIQ0nd 12 | GTmOLCwI 13 | =8FyH 14 | -----END PGP PUBLIC KEY BLOCK----- -------------------------------------------------------------------------------- /scripts/keys/proofofkeags.asc: -------------------------------------------------------------------------------- 1 | -----BEGIN PGP PUBLIC KEY BLOCK----- 2 | 3 | mDMEZlZ1MRYJKwYBBAHaRw8BAQdAZsa54hBDrjAnuj56IGJYcIszHvasEPFVvcO9 4 | 3WBUS3q0L0tlYWdhbiBNY0NsZWxsYW5kIDxrZWFnYW4ubWNjbGVsbGFuZEBnbWFp 5 | bC5jb20+iJkEExYKAEEWIQRSlaR3/8gGTXBXsZH6fmXJUfEkOQUCZlZ1MQIbAwUJ 6 | BaOagAULCQgHAgIiAgYVCgkICwIEFgIDAQIeBwIXgAAKCRD6fmXJUfEkOU1fAQDW 7 | wdx8AF8QdITRvY299R6Y9348N4EIa9mq6bYeh+d0HwD7BPEkKquPNncuUmqJ8EAe 8 | uGOQX0xs+0YyynMIHulnnQi4OARmVnUxEgorBgEEAZdVAQUBAQdAOvF6kho3KmjN 9 | OQQX/bxng+Tgy4hz34BJojWJdSpn/gYDAQgHiH4EGBYKACYWIQRSlaR3/8gGTXBX 10 | sZH6fmXJUfEkOQUCZlZ1MQIbDAUJBaOagAAKCRD6fmXJUfEkOaVeAP4rJD+kvC0D 11 | jffwmx9w0L6Grb4KPX1FTm7UBq7JSZExHgEAn27BOcf4lDoRZRa27K6jjTNd96Nk 12 | 2MU5hr1pnbZNfQQ= 13 | =3tMW 14 | -----END PGP PUBLIC KEY BLOCK----- 15 | -------------------------------------------------------------------------------- /scripts/keys/ziggie1984.asc: -------------------------------------------------------------------------------- 1 | -----BEGIN PGP PUBLIC KEY BLOCK----- 2 | 3 | mDMEYaLTVBYJKwYBBAHaRw8BAQdAJ6/QY9ydBGzO1O0kZfMrXWTYXNYjHFd6R7zu 4 | trxIczG0N3ppZ2dpZSAoIkZpcnN0IHppZ2dpZSBLZXkiKSA8emlnZ2llMTk4NEBw 5 | cm90b25tYWlsLmNvbT6ImgQTFgoAQgIbAwULCQgHAgMiAgEGFQoJCAsCBBYCAwEC 6 | HgcCF4AWIQRfdUN+EWlfhtUMEbsa/5xNztbWZgUCZWndVwUJB4lxAwAKCRAa/5xN 7 | ztbWZrZVAP9E/jZ2HVmu+o6uT5OD2hr4fGla9Hnj0cKI9M7U1JVI1gEAqNKUkTGx 8 | jMJDwWtQFumrLA0N0ivZEwf1pboJL2ktiQa4OARhotNUEgorBgEEAZdVAQUBAQdA 9 | bxFZFi9Ita8rBveytJ1ryElyzKNXuFHrB+M9qn22sEgDAQgHiH4EGBYKACYCGwwW 10 | IQRfdUN+EWlfhtUMEbsa/5xNztbWZgUCZWnc1wUJB4lwgwAKCRAa/5xNztbWZhkT 11 | AQC5IHM6yqeeofk6jOQszz/QH28Mf8G1zK1NSjKA3eCFnAD8C40gfkUAjciYYr/P 12 | 1zEF2JZzcd2DFJE2HDqkCaB9Ugw= 13 | =9UuF 14 | -----END PGP PUBLIC KEY BLOCK----- 15 | -------------------------------------------------------------------------------- /scripts/tidy_modules.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | SUBMODULES=$(find . -mindepth 2 -name "go.mod" | cut -d'/' -f2) 4 | 5 | 6 | # Run 'go mod tidy' for root. 7 | go mod tidy 8 | 9 | # Run 'go mod tidy' for each module. 10 | for submodule in $SUBMODULES 11 | do 12 | pushd $submodule 13 | 14 | go mod tidy 15 | 16 | popd 17 | done 18 | -------------------------------------------------------------------------------- /scripts/unit-test-flake-hunter.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Check if pkg and case variables are provided. 4 | if [ $# -lt 2 ] || [ $# -gt 3 ]; then 5 | echo "Usage: $0 [timeout]" 6 | exit 1 7 | fi 8 | 9 | pkg=$1 10 | case=$2 11 | timeout=${3:-30s} # Default to 30s if not provided. 12 | 13 | counter=0 14 | 15 | # Run the command in a loop until it fails. 16 | while output=$(go clean -testcache && make unit-debug log="stdlog trace" pkg=$pkg case=$case timeout=$timeout 2>&1); do 17 | ((counter++)) 18 | echo "Test $case passed, count: $counter" 19 | done 20 | 21 | # Only log the output when it fails. 22 | echo "Test $case failed. Output:" 23 | echo "$output" 24 | -------------------------------------------------------------------------------- /scripts/unit_test_modules.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | IGNORE="tools" 4 | SUBMODULES=$(find . -mindepth 2 -name "go.mod" | cut -d'/' -f2 | grep -v "$IGNORE") 5 | 6 | for submodule in $SUBMODULES 7 | do 8 | pushd $submodule 9 | 10 | echo "Running submodule unit tests in $(pwd)" 11 | echo "testing $submodule..." 12 | go test -timeout=5m || exit 1 13 | 14 | if [[ "$submodule" == "kvdb" ]] 15 | then 16 | echo "testing $submodule with sqlite..." 17 | go test -tags="kvdb_sqlite" -timeout=5m || exit 1 18 | 19 | echo "testing $submodule with postgres..." 20 | go test -tags="kvdb_postgres" -timeout=5m || exit 1 21 | 22 | echo "testing $submodule with etcd..." 23 | go test -tags="kvdb_etcd" -timeout=5m || exit 1 24 | fi 25 | 26 | popd 27 | done 28 | -------------------------------------------------------------------------------- /shachain/producer_test.go: -------------------------------------------------------------------------------- 1 | package shachain 2 | 3 | import ( 4 | "bytes" 5 | "testing" 6 | 7 | "github.com/btcsuite/btcd/chaincfg/chainhash" 8 | ) 9 | 10 | // TestShaChainProducerRestore checks the ability of shachain producer to be 11 | // properly recreated from binary representation. 12 | func TestShaChainProducerRestore(t *testing.T) { 13 | t.Parallel() 14 | 15 | var err error 16 | 17 | seed := chainhash.DoubleHashH([]byte("shachaintest")) 18 | sender := NewRevocationProducer(seed) 19 | 20 | s1, err := sender.AtIndex(0) 21 | if err != nil { 22 | t.Fatal(err) 23 | } 24 | 25 | var b bytes.Buffer 26 | if err := sender.Encode(&b); err != nil { 27 | t.Fatal(err) 28 | } 29 | 30 | sender, err = NewRevocationProducerFromBytes(b.Bytes()) 31 | if err != nil { 32 | t.Fatal(err) 33 | } 34 | 35 | s3, err := sender.AtIndex(0) 36 | if err != nil { 37 | t.Fatal(err) 38 | } 39 | 40 | if !s1.IsEqual(s3) { 41 | t.Fatalf("secrets should match: %v:%v", s1.String(), s3.String()) 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /signal/log.go: -------------------------------------------------------------------------------- 1 | package signal 2 | 3 | import "github.com/btcsuite/btclog/v2" 4 | 5 | // log is a logger that is initialized with no output filters. This 6 | // means the package will not perform any logging by default until the caller 7 | // requests it. 8 | var log btclog.Logger 9 | 10 | // The default amount of logging is none. 11 | func init() { 12 | DisableLog() 13 | } 14 | 15 | // DisableLog disables all library log output. Logging output is disabled 16 | // by default until UseLogger is called. 17 | func DisableLog() { 18 | UseLogger(btclog.Disabled) 19 | } 20 | 21 | // UseLogger uses a specified Logger to output package logging info. 22 | // This should be used in preference to SetLogWriter if the caller is also 23 | // using btclog. 24 | func UseLogger(logger btclog.Logger) { 25 | log = logger 26 | } 27 | -------------------------------------------------------------------------------- /sqlc.yaml: -------------------------------------------------------------------------------- 1 | version: "2" 2 | sql: 3 | - engine: "postgresql" 4 | schema: "sqldb/sqlc/migrations" 5 | queries: "sqldb/sqlc/queries" 6 | gen: 7 | go: 8 | out: sqldb/sqlc 9 | package: sqlc 10 | emit_interface: true 11 | -------------------------------------------------------------------------------- /sqldb/log.go: -------------------------------------------------------------------------------- 1 | package sqldb 2 | 3 | import "github.com/btcsuite/btclog/v2" 4 | 5 | // Subsystem defines the logging code for this subsystem. 6 | const Subsystem = "SQLD" 7 | 8 | // log is a logger that is initialized with no output filters. This 9 | // means the package will not perform any logging by default until the caller 10 | // requests it. 11 | var log = btclog.Disabled 12 | 13 | // DisableLog disables all library log output. Logging output is disabled 14 | // by default until UseLogger is called. 15 | func DisableLog() { 16 | UseLogger(btclog.Disabled) 17 | } 18 | 19 | // UseLogger uses a specified Logger to output package logging info. 20 | // This should be used in preference to SetLogWriter if the caller is also 21 | // using btclog. 22 | func UseLogger(logger btclog.Logger) { 23 | log = logger 24 | } 25 | -------------------------------------------------------------------------------- /sqldb/migrations_dev.go: -------------------------------------------------------------------------------- 1 | //go:build test_db_postgres || test_db_sqlite 2 | 3 | package sqldb 4 | 5 | var migrationAdditions = []MigrationConfig{ 6 | { 7 | Name: "000007_graph", 8 | Version: 8, 9 | SchemaVersion: 7, 10 | }, 11 | } 12 | -------------------------------------------------------------------------------- /sqldb/migrations_prod.go: -------------------------------------------------------------------------------- 1 | //go:build !test_db_postgres && !test_db_sqlite 2 | 3 | package sqldb 4 | 5 | var migrationAdditions []MigrationConfig 6 | -------------------------------------------------------------------------------- /sqldb/postgres_test.go: -------------------------------------------------------------------------------- 1 | //go:build test_db_postgres 2 | // +build test_db_postgres 3 | 4 | package sqldb 5 | 6 | import ( 7 | "testing" 8 | ) 9 | 10 | // NewTestDB is a helper function that creates a Postgres database for testing. 11 | func NewTestDB(t *testing.T) *PostgresStore { 12 | pgFixture := NewTestPgFixture(t, DefaultPostgresFixtureLifetime) 13 | t.Cleanup(func() { 14 | pgFixture.TearDown(t) 15 | }) 16 | 17 | return NewTestPostgresDB(t, pgFixture) 18 | } 19 | 20 | // NewTestDBWithVersion is a helper function that creates a Postgres database 21 | // for testing and migrates it to the given version. 22 | func NewTestDBWithVersion(t *testing.T, version uint) *PostgresStore { 23 | pgFixture := NewTestPgFixture(t, DefaultPostgresFixtureLifetime) 24 | t.Cleanup(func() { 25 | pgFixture.TearDown(t) 26 | }) 27 | 28 | return NewTestPostgresDBWithVersion(t, pgFixture, version) 29 | } 30 | -------------------------------------------------------------------------------- /sqldb/schemas.go: -------------------------------------------------------------------------------- 1 | package sqldb 2 | 3 | import ( 4 | "embed" 5 | ) 6 | 7 | //go:embed sqlc/migrations/*.up.sql 8 | var sqlSchemas embed.FS 9 | -------------------------------------------------------------------------------- /sqldb/sqlc/db.go: -------------------------------------------------------------------------------- 1 | // Code generated by sqlc. DO NOT EDIT. 2 | // versions: 3 | // sqlc v1.29.0 4 | 5 | package sqlc 6 | 7 | import ( 8 | "context" 9 | "database/sql" 10 | ) 11 | 12 | type DBTX interface { 13 | ExecContext(context.Context, string, ...interface{}) (sql.Result, error) 14 | PrepareContext(context.Context, string) (*sql.Stmt, error) 15 | QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error) 16 | QueryRowContext(context.Context, string, ...interface{}) *sql.Row 17 | } 18 | 19 | func New(db DBTX) *Queries { 20 | return &Queries{db: db} 21 | } 22 | 23 | type Queries struct { 24 | db DBTX 25 | } 26 | 27 | func (q *Queries) WithTx(tx *sql.Tx) *Queries { 28 | return &Queries{ 29 | db: tx, 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /sqldb/sqlc/migrations/000001_invoices.down.sql: -------------------------------------------------------------------------------- 1 | DROP INDEX IF EXISTS invoice_payments_invoice_id_idx; 2 | DROP INDEX IF EXISTS invoice_payments_settled_at_idx; 3 | DROP TABLE IF EXISTS invoice_payments; 4 | 5 | DROP INDEX IF EXISTS invoice_htlc_custom_records_htlc_id_idx; 6 | DROP TABLE IF EXISTS invoice_htlc_custom_records; 7 | 8 | DROP INDEX IF EXISTS invoice_htlc_invoice_id_idx; 9 | DROP TABLE IF EXISTS invoice_htlcs; 10 | 11 | DROP INDEX IF EXISTS invoice_feature_invoice_id_idx; 12 | DROP TABLE IF EXISTS invoice_features; 13 | 14 | DROP INDEX IF EXISTS invoices_created_at_idx; 15 | DROP INDEX IF EXISTS invoices_state_idx; 16 | DROP INDEX IF EXISTS invoices_payment_addr_idx; 17 | DROP INDEX IF EXISTS invoices_preimage_idx; 18 | DROP INDEX IF EXISTS invoices_hash_idx; 19 | DROP TABLE IF EXISTS invoices; 20 | -------------------------------------------------------------------------------- /sqldb/sqlc/migrations/000002_amp_invoices.down.sql: -------------------------------------------------------------------------------- 1 | DROP INDEX IF EXISTS amp_htlcs_htlc_id_idx; 2 | DROP INDEX IF EXISTS amp_htlcs_invoice_id_idx; 3 | DROP INDEX IF EXISTS amp_htlcs_set_id_idx; 4 | DROP TABLE IF EXISTS amp_invoice_htlcs; 5 | 6 | DROP INDEX IF EXISTS amp_invoice_payments_invoice_id_idx; 7 | DROP TABLE IF EXISTS amp_invoice_payments; 8 | 9 | -------------------------------------------------------------------------------- /sqldb/sqlc/migrations/000003_invoice_events.down.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE IF EXISTS invoice_events; 2 | DROP INDEX IF EXISTS invoice_events_added_at_idx; 3 | DROP INDEX IF EXISTS invoice_events_event_type_idx; 4 | DROP INDEX IF EXISTS invoice_events_invoice_id_idx; 5 | DROP INDEX IF EXISTS invoice_events_set_id_idx; 6 | DROP TABLE IF EXISTS invoice_event_types; 7 | -------------------------------------------------------------------------------- /sqldb/sqlc/migrations/000004_invoice_expiry_fix.down.sql: -------------------------------------------------------------------------------- 1 | -- Given that all expiries are changed in this migration we won't be able to 2 | -- roll back to the previous values. 3 | -------------------------------------------------------------------------------- /sqldb/sqlc/migrations/000004_invoice_expiry_fix.up.sql: -------------------------------------------------------------------------------- 1 | -- Update the expiry for all records in the invoices table. This is needed as 2 | -- previously we stored raw time.Duration values which are 64 bit integers and 3 | -- are used to express duration in nanoseconds however the intent is to store 4 | -- invoice expiry in seconds. 5 | 6 | -- Update the expiry to 86400 seconds (24 hours) for non-AMP invoices. 7 | UPDATE invoices 8 | SET expiry = 86400 9 | WHERE is_amp = FALSE; 10 | 11 | -- Update the expiry to 2592000 seconds (30 days) for AMP invoices 12 | UPDATE invoices 13 | SET expiry = 2592000 14 | WHERE is_amp = TRUE; 15 | -------------------------------------------------------------------------------- /sqldb/sqlc/migrations/000005_migration_tracker.down.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE IF EXISTS migration_tracker; 2 | -------------------------------------------------------------------------------- /sqldb/sqlc/migrations/000006_invoice_migration.down.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE IF EXISTS invoice_payment_hashes; 2 | -------------------------------------------------------------------------------- /sqldb/sqlc/migrations/000006_invoice_migration.up.sql: -------------------------------------------------------------------------------- 1 | -- invoice_payment_hashes table contains the hash of the invoices. This table 2 | -- is used during KV to SQL invoice migration as in our KV representation we 3 | -- don't have a mapping from hash to add index. 4 | CREATE TABLE IF NOT EXISTS invoice_payment_hashes ( 5 | -- id represents is the key of the invoice in the KV store. 6 | id INTEGER PRIMARY KEY, 7 | 8 | -- add_index is the KV add index of the invoice. 9 | add_index BIGINT NOT NULL, 10 | 11 | -- hash is the payment hash for this invoice. 12 | hash BLOB 13 | ); 14 | 15 | -- Create an indexes on the add_index and hash columns to speed up lookups. 16 | CREATE INDEX IF NOT EXISTS invoice_payment_hashes_add_index_idx ON invoice_payment_hashes(add_index); 17 | CREATE INDEX IF NOT EXISTS invoice_payment_hashes_hash_idx ON invoice_payment_hashes(hash); 18 | -------------------------------------------------------------------------------- /sqldb/sqlc/migrations/000007_graph.down.sql: -------------------------------------------------------------------------------- 1 | -- Drop indexes. 2 | DROP INDEX IF EXISTS nodes_unique; 3 | DROP INDEX IF EXISTS node_extra_types_unique; 4 | DROP INDEX IF EXISTS node_features_unique; 5 | DROP INDEX IF EXISTS node_addresses_unique; 6 | DROP INDEX IF EXISTS source_nodes_unique; 7 | 8 | -- Drop tables in order of reverse dependencies. 9 | DROP TABLE IF EXISTS source_nodes; 10 | DROP TABLE IF EXISTS node_addresses; 11 | DROP TABLE IF EXISTS node_features; 12 | DROP TABLE IF EXISTS node_extra_types; 13 | DROP TABLE IF EXISTS nodes; -------------------------------------------------------------------------------- /sqldb/sqlc/queries/migration.sql: -------------------------------------------------------------------------------- 1 | -- name: SetMigration :exec 2 | INSERT INTO 3 | migration_tracker (version, migration_time) 4 | VALUES ($1, $2); 5 | 6 | -- name: GetMigration :one 7 | SELECT 8 | migration_time 9 | FROM 10 | migration_tracker 11 | WHERE 12 | version = $1; 13 | 14 | -- name: GetDatabaseVersion :one 15 | SELECT 16 | version 17 | FROM 18 | migration_tracker 19 | ORDER BY 20 | version DESC 21 | LIMIT 1; 22 | -------------------------------------------------------------------------------- /sqldb/sqlite_test.go: -------------------------------------------------------------------------------- 1 | //go:build !test_db_postgres 2 | // +build !test_db_postgres 3 | 4 | package sqldb 5 | 6 | import ( 7 | "testing" 8 | ) 9 | 10 | // NewTestDB is a helper function that creates an SQLite database for testing. 11 | func NewTestDB(t *testing.T) *SqliteStore { 12 | return NewTestSqliteDB(t) 13 | } 14 | 15 | // NewTestDBWithVersion is a helper function that creates an SQLite database 16 | // for testing and migrates it to the given version. 17 | func NewTestDBWithVersion(t *testing.T, version uint) *SqliteStore { 18 | return NewTestSqliteDBWithVersion(t, version) 19 | } 20 | -------------------------------------------------------------------------------- /subscribe/interface.go: -------------------------------------------------------------------------------- 1 | package subscribe 2 | 3 | // Subscription is an interface implemented by subscriptions to a server 4 | // providing updates. 5 | type Subscription interface { 6 | // Updates returns a read-only channel where the updates the client has 7 | // subscribed to will be delivered. 8 | Updates() <-chan interface{} 9 | 10 | // Quit is a channel that will be closed in case the server decides to 11 | // no longer deliver updates to this client. 12 | Quit() <-chan struct{} 13 | 14 | // Cancel should be called in case the client no longer wants to 15 | // subscribe for updates from the server. 16 | Cancel() 17 | } 18 | -------------------------------------------------------------------------------- /sweep/defaults.go: -------------------------------------------------------------------------------- 1 | package sweep 2 | 3 | import ( 4 | "github.com/lightningnetwork/lnd/lnwallet/chainfee" 5 | ) 6 | 7 | var ( 8 | // DefaultMaxFeeRate is the default maximum fee rate allowed within the 9 | // UtxoSweeper. The current value is equivalent to a fee rate of 1,000 10 | // sat/vbyte. 11 | DefaultMaxFeeRate chainfee.SatPerVByte = 1e3 12 | ) 13 | -------------------------------------------------------------------------------- /sweep/log.go: -------------------------------------------------------------------------------- 1 | package sweep 2 | 3 | import ( 4 | "github.com/btcsuite/btclog/v2" 5 | "github.com/lightningnetwork/lnd/build" 6 | ) 7 | 8 | // log is a logger that is initialized with no output filters. This means the 9 | // package will not perform any logging by default until the caller requests 10 | // it. 11 | var log btclog.Logger 12 | 13 | // The default amount of logging is none. 14 | func init() { 15 | UseLogger(build.NewSubLogger("SWPR", nil)) 16 | } 17 | 18 | // DisableLog disables all library log output. Logging output is disabled by 19 | // default until UseLogger is called. 20 | func DisableLog() { 21 | UseLogger(btclog.Disabled) 22 | } 23 | 24 | // UseLogger uses a specified Logger to output package logging info. This 25 | // should be used in preference to SetLogWriter if the caller is also using 26 | // btclog. 27 | func UseLogger(logger btclog.Logger) { 28 | log = logger 29 | } 30 | -------------------------------------------------------------------------------- /sweep/setup_test.go: -------------------------------------------------------------------------------- 1 | package sweep 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/lightningnetwork/lnd/kvdb" 7 | ) 8 | 9 | func TestMain(m *testing.M) { 10 | kvdb.RunTests(m) 11 | } 12 | -------------------------------------------------------------------------------- /sweeper_wallet.go: -------------------------------------------------------------------------------- 1 | package lnd 2 | 3 | import ( 4 | "github.com/btcsuite/btcd/chaincfg/chainhash" 5 | "github.com/lightningnetwork/lnd/lnwallet" 6 | ) 7 | 8 | // sweeperWallet is a wrapper around the LightningWallet that implements the 9 | // sweeper's Wallet interface. 10 | type sweeperWallet struct { 11 | *lnwallet.LightningWallet 12 | } 13 | 14 | // newSweeperWallet creates a new sweeper wallet from the given 15 | // LightningWallet. 16 | func newSweeperWallet(w *lnwallet.LightningWallet) *sweeperWallet { 17 | return &sweeperWallet{ 18 | LightningWallet: w, 19 | } 20 | } 21 | 22 | // CancelRebroadcast cancels the rebroadcast of the given transaction. 23 | func (s *sweeperWallet) CancelRebroadcast(txid chainhash.Hash) { 24 | // For neutrino, we don't config the rebroadcaster for the wallet as it 25 | // manages the rebroadcasting logic in neutrino itself. 26 | if s.Cfg.Rebroadcaster != nil { 27 | s.Cfg.Rebroadcaster.MarkAsConfirmed(txid) 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /ticker/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/lightningnetwork/lnd/ticker 2 | 3 | go 1.19 4 | -------------------------------------------------------------------------------- /tlv/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/lightningnetwork/lnd/tlv 2 | 3 | require ( 4 | github.com/btcsuite/btcd v0.24.1-0.20240301210420-1a2b599bf1af 5 | github.com/btcsuite/btcd/btcec/v2 v2.3.2 6 | github.com/davecgh/go-spew v1.1.1 7 | github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 8 | github.com/lightningnetwork/lnd/fn/v2 v2.0.2 9 | github.com/stretchr/testify v1.8.4 10 | golang.org/x/exp v0.0.0-20231226003508-02704c960a9b 11 | ) 12 | 13 | require ( 14 | github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0 // indirect 15 | github.com/kr/pretty v0.3.0 // indirect 16 | github.com/pmezard/go-difflib v1.0.0 // indirect 17 | github.com/rogpeppe/go-internal v1.9.0 // indirect 18 | golang.org/x/crypto v0.16.0 // indirect 19 | golang.org/x/sync v0.7.0 // indirect 20 | golang.org/x/sys v0.15.0 // indirect 21 | gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect 22 | gopkg.in/yaml.v3 v3.0.1 // indirect 23 | ) 24 | 25 | go 1.19 26 | -------------------------------------------------------------------------------- /tlv/tlv_type_param.go: -------------------------------------------------------------------------------- 1 | package tlv 2 | 3 | import "fmt" 4 | 5 | // TlvType is an interface used to enable binding the integer type of a TLV 6 | // record to the type at compile time. 7 | type TlvType interface { 8 | // TypeVal returns the integer TLV type that this TlvType struct 9 | // instance maps to. 10 | TypeVal() Type 11 | 12 | // tlv is an internal method to make this a "sealed" interface, meaning 13 | // only this package can declare new instances. 14 | tlv() 15 | } 16 | 17 | //go:generate go run internal/gen/gen_tlv_types.go -o tlv_types_generated.go 18 | 19 | func main() { 20 | // This function is only here to satisfy the go:generate directive. 21 | fmt.Println("Generating TLV type structures...") 22 | } 23 | -------------------------------------------------------------------------------- /tools/.custom-gcl.yml: -------------------------------------------------------------------------------- 1 | version: v1.64.5 2 | plugins: 3 | - module: 'github.com/lightningnetwork/lnd/tools/linters' 4 | path: ./linters -------------------------------------------------------------------------------- /tools/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM golang:1.23.9 2 | 3 | RUN apt-get update && apt-get install -y git 4 | ENV GOCACHE=/tmp/build/.cache 5 | ENV GOMODCACHE=/tmp/build/.modcache 6 | 7 | COPY . /tmp/tools 8 | 9 | RUN cd /tmp \ 10 | && mkdir -p /tmp/build/.cache \ 11 | && mkdir -p /tmp/build/.modcache \ 12 | && cd /tmp/tools \ 13 | && go install -trimpath github.com/golangci/golangci-lint/cmd/golangci-lint \ 14 | && golangci-lint custom \ 15 | && mv ./custom-gcl /usr/local/bin/custom-gcl \ 16 | && chmod -R 777 /tmp/build/ \ 17 | && git config --global --add safe.directory /build 18 | 19 | WORKDIR /build 20 | -------------------------------------------------------------------------------- /tools/linters/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/lightningnetwork/lnd/tools/linters 2 | 3 | go 1.22.6 4 | 5 | require ( 6 | github.com/golangci/plugin-module-register v0.1.1 7 | github.com/stretchr/testify v1.10.0 8 | golang.org/x/tools v0.30.0 9 | ) 10 | 11 | require ( 12 | github.com/davecgh/go-spew v1.1.1 // indirect 13 | github.com/pmezard/go-difflib v1.0.0 // indirect 14 | gopkg.in/yaml.v3 v3.0.1 // indirect 15 | ) 16 | -------------------------------------------------------------------------------- /tools/tools.go: -------------------------------------------------------------------------------- 1 | //go:build tools 2 | // +build tools 3 | 4 | package lnd 5 | 6 | // The other imports represent our build tools. Instead of defining a commit we 7 | // want to use for those golang based tools, we use the go mod versioning system 8 | // to unify the way we manage dependencies. So we define our build tool 9 | // dependencies here and pin the version in go.mod. 10 | import ( 11 | _ "github.com/btcsuite/btcd" 12 | _ "github.com/golangci/golangci-lint/cmd/golangci-lint" 13 | _ "github.com/rinchsan/gosimports/cmd/gosimports" 14 | ) 15 | -------------------------------------------------------------------------------- /tor/README.md: -------------------------------------------------------------------------------- 1 | tor 2 | === 3 | 4 | The tor package contains utility functions that allow for interacting with the 5 | Tor daemon. So far, supported functions include: 6 | 7 | * Routing all traffic over Tor's exposed SOCKS5 proxy. 8 | * Routing DNS queries over Tor (A, AAAA, SRV). 9 | * Limited Tor Control functionality (synchronous messages only). So far, this 10 | includes: 11 | * Support for SAFECOOKIE, HASHEDPASSWORD, and NULL authentication methods. 12 | * Creating v2 and v3 onion services. 13 | 14 | In the future, the Tor Control functionality will be extended to support v3 15 | onion services, asynchronous messages, etc. 16 | 17 | ## Installation and Updating 18 | 19 | ```shell 20 | $ go get -u github.com/lightningnetwork/lnd/tor 21 | ``` 22 | -------------------------------------------------------------------------------- /tor/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/lightningnetwork/lnd/tor 2 | 3 | require ( 4 | github.com/btcsuite/btcd v0.23.3 5 | github.com/btcsuite/btclog/v2 v2.0.0-20241017175713-3428138b75c7 6 | github.com/miekg/dns v1.1.43 7 | github.com/stretchr/testify v1.8.2 8 | golang.org/x/net v0.17.0 9 | ) 10 | 11 | require ( 12 | github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 // indirect 13 | github.com/btcsuite/btclog v0.0.0-20241003133417-09c4e92e319c // indirect 14 | github.com/davecgh/go-spew v1.1.1 // indirect 15 | github.com/kr/pretty v0.3.0 // indirect 16 | github.com/pmezard/go-difflib v1.0.0 // indirect 17 | github.com/rogpeppe/go-internal v1.9.0 // indirect 18 | github.com/stretchr/objx v0.5.0 // indirect 19 | golang.org/x/crypto v0.14.0 // indirect 20 | golang.org/x/sync v0.2.0 // indirect 21 | golang.org/x/sys v0.13.0 // indirect 22 | gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect 23 | gopkg.in/yaml.v3 v3.0.1 // indirect 24 | ) 25 | 26 | go 1.21 27 | -------------------------------------------------------------------------------- /tor/log.go: -------------------------------------------------------------------------------- 1 | package tor 2 | 3 | import "github.com/btcsuite/btclog/v2" 4 | 5 | // Subsystem defines the logging code for this subsystem. 6 | const Subsystem = "TORC" // TORC as in Tor Controller. 7 | 8 | // log is a logger that is initialized with no output filters. This 9 | // means the package will not perform any logging by default until the caller 10 | // requests it. 11 | var log = btclog.Disabled 12 | 13 | // DisableLog disables all library log output. Logging output is disabled 14 | // by default until UseLogger is called. 15 | func DisableLog() { 16 | UseLogger(btclog.Disabled) 17 | } 18 | 19 | // UseLogger uses a specified Logger to output package logging info. 20 | // This should be used in preference to SetLogWriter if the caller is also 21 | // using btclog. 22 | func UseLogger(logger btclog.Logger) { 23 | log = logger 24 | } 25 | -------------------------------------------------------------------------------- /watchtower/errors.go: -------------------------------------------------------------------------------- 1 | package watchtower 2 | 3 | import "errors" 4 | 5 | var ( 6 | // ErrNoListeners signals that no listening ports were provided, 7 | // rendering the tower unable to receive client requests. 8 | ErrNoListeners = errors.New("no listening ports were specified") 9 | 10 | // ErrNoNetwork signals that no tor.Net is provided in the Config, which 11 | // prevents resolution of listening addresses. 12 | ErrNoNetwork = errors.New("no network specified, must be tor or clearnet") 13 | ) 14 | -------------------------------------------------------------------------------- /watchtower/interface.go: -------------------------------------------------------------------------------- 1 | package watchtower 2 | 3 | import ( 4 | "net" 5 | 6 | "github.com/lightningnetwork/lnd/watchtower/lookout" 7 | "github.com/lightningnetwork/lnd/watchtower/wtserver" 8 | ) 9 | 10 | // DB abstracts the persistent functionality required to run the watchtower 11 | // daemon. It composes the database interfaces required by the lookout and 12 | // wtserver subsystems. 13 | type DB interface { 14 | lookout.DB 15 | wtserver.DB 16 | } 17 | 18 | // AddressNormalizer is a function signature that allows the tower to resolve 19 | // TCP addresses on clear or onion networks. 20 | type AddressNormalizer func(addrs []string, defaultPort string, 21 | resolver func(string, string) (*net.TCPAddr, error)) ([]net.Addr, error) 22 | -------------------------------------------------------------------------------- /watchtower/lookout/log.go: -------------------------------------------------------------------------------- 1 | package lookout 2 | 3 | import ( 4 | "github.com/btcsuite/btclog/v2" 5 | "github.com/lightningnetwork/lnd/build" 6 | ) 7 | 8 | // log is a logger that is initialized with no output filters. This 9 | // means the package will not perform any logging by default until the caller 10 | // requests it. 11 | var log btclog.Logger 12 | 13 | // The default amount of logging is none. 14 | func init() { 15 | UseLogger(build.NewSubLogger("WTWR", nil)) 16 | } 17 | 18 | // DisableLog disables all library log output. Logging output is disabled 19 | // by default until UseLogger is called. 20 | func DisableLog() { 21 | UseLogger(btclog.Disabled) 22 | } 23 | 24 | // UseLogger uses a specified Logger to output package logging info. 25 | // This should be used in preference to SetLogWriter if the caller is also 26 | // using btclog. 27 | func UseLogger(logger btclog.Logger) { 28 | log = logger 29 | } 30 | -------------------------------------------------------------------------------- /watchtower/wtclient/log.go: -------------------------------------------------------------------------------- 1 | package wtclient 2 | 3 | import ( 4 | "github.com/btcsuite/btclog/v2" 5 | "github.com/lightningnetwork/lnd/build" 6 | ) 7 | 8 | // log is a logger that is initialized with no output filters. This 9 | // means the package will not perform any logging by default until the caller 10 | // requests it. 11 | var log btclog.Logger 12 | 13 | // The default amount of logging is none. 14 | func init() { 15 | UseLogger(build.NewSubLogger("WTCL", nil)) 16 | } 17 | 18 | // DisableLog disables all library log output. Logging output is disabled 19 | // by default until UseLogger is called. 20 | func DisableLog() { 21 | UseLogger(btclog.Disabled) 22 | } 23 | 24 | // UseLogger uses a specified Logger to output package logging info. 25 | // This should be used in preference to SetLogWriter if the caller is also 26 | // using btclog. 27 | func UseLogger(logger btclog.Logger) { 28 | log = logger 29 | } 30 | -------------------------------------------------------------------------------- /watchtower/wtdb/migration1/log.go: -------------------------------------------------------------------------------- 1 | package migration1 2 | 3 | import ( 4 | "github.com/btcsuite/btclog/v2" 5 | ) 6 | 7 | // log is a logger that is initialized as disabled. This means the package will 8 | // not perform any logging by default until a logger is set. 9 | var log = btclog.Disabled 10 | 11 | // UseLogger uses a specified Logger to output package logging info. 12 | func UseLogger(logger btclog.Logger) { 13 | log = logger 14 | } 15 | -------------------------------------------------------------------------------- /watchtower/wtdb/migration2/codec.go: -------------------------------------------------------------------------------- 1 | package migration2 2 | 3 | import "encoding/hex" 4 | 5 | // ChannelID is a series of 32-bytes that uniquely identifies all channels 6 | // within the network. The ChannelID is computed using the outpoint of the 7 | // funding transaction (the txid, and output index). Given a funding output the 8 | // ChannelID can be calculated by XOR'ing the big-endian serialization of the 9 | // txid and the big-endian serialization of the output index, truncated to 10 | // 2 bytes. 11 | type ChannelID [32]byte 12 | 13 | // String returns the string representation of the ChannelID. This is just the 14 | // hex string encoding of the ChannelID itself. 15 | func (c ChannelID) String() string { 16 | return hex.EncodeToString(c[:]) 17 | } 18 | -------------------------------------------------------------------------------- /watchtower/wtdb/migration2/log.go: -------------------------------------------------------------------------------- 1 | package migration2 2 | 3 | import ( 4 | "github.com/btcsuite/btclog/v2" 5 | ) 6 | 7 | // log is a logger that is initialized as disabled. This means the package will 8 | // not perform any logging by default until a logger is set. 9 | var log = btclog.Disabled 10 | 11 | // UseLogger uses a specified Logger to output package logging info. 12 | func UseLogger(logger btclog.Logger) { 13 | log = logger 14 | } 15 | -------------------------------------------------------------------------------- /watchtower/wtdb/migration3/codec.go: -------------------------------------------------------------------------------- 1 | package migration3 2 | 3 | import ( 4 | "encoding/hex" 5 | ) 6 | 7 | // ChannelID is a series of 32-bytes that uniquely identifies all channels 8 | // within the network. The ChannelID is computed using the outpoint of the 9 | // funding transaction (the txid, and output index). Given a funding output the 10 | // ChannelID can be calculated by XOR'ing the big-endian serialization of the 11 | // txid and the big-endian serialization of the output index, truncated to 12 | // 2 bytes. 13 | type ChannelID [32]byte 14 | 15 | // String returns the string representation of the ChannelID. This is just the 16 | // hex string encoding of the ChannelID itself. 17 | func (c ChannelID) String() string { 18 | return hex.EncodeToString(c[:]) 19 | } 20 | -------------------------------------------------------------------------------- /watchtower/wtdb/migration3/log.go: -------------------------------------------------------------------------------- 1 | package migration3 2 | 3 | import ( 4 | "github.com/btcsuite/btclog/v2" 5 | ) 6 | 7 | // log is a logger that is initialized as disabled. This means the package will 8 | // not perform any logging by default until a logger is set. 9 | var log = btclog.Disabled 10 | 11 | // UseLogger uses a specified Logger to output package logging info. 12 | func UseLogger(logger btclog.Logger) { 13 | log = logger 14 | } 15 | -------------------------------------------------------------------------------- /watchtower/wtdb/migration4/log.go: -------------------------------------------------------------------------------- 1 | package migration4 2 | 3 | import ( 4 | "github.com/btcsuite/btclog/v2" 5 | ) 6 | 7 | // log is a logger that is initialized as disabled. This means the package will 8 | // not perform any logging by default until a logger is set. 9 | var log = btclog.Disabled 10 | 11 | // UseLogger uses a specified Logger to output package logging info. 12 | func UseLogger(logger btclog.Logger) { 13 | log = logger 14 | } 15 | -------------------------------------------------------------------------------- /watchtower/wtdb/migration5/log.go: -------------------------------------------------------------------------------- 1 | package migration5 2 | 3 | import ( 4 | "github.com/btcsuite/btclog/v2" 5 | ) 6 | 7 | // log is a logger that is initialized as disabled. This means the package will 8 | // not perform any logging by default until a logger is set. 9 | var log = btclog.Disabled 10 | 11 | // UseLogger uses a specified Logger to output package logging info. 12 | func UseLogger(logger btclog.Logger) { 13 | log = logger 14 | } 15 | -------------------------------------------------------------------------------- /watchtower/wtdb/migration6/codec.go: -------------------------------------------------------------------------------- 1 | package migration6 2 | 3 | import ( 4 | "encoding/hex" 5 | ) 6 | 7 | // SessionIDSize is 33-bytes; it is a serialized, compressed public key. 8 | const SessionIDSize = 33 9 | 10 | // SessionID is created from the remote public key of a client, and serves as a 11 | // unique identifier and authentication for sending state updates. 12 | type SessionID [SessionIDSize]byte 13 | 14 | // String returns a hex encoding of the session id. 15 | func (s SessionID) String() string { 16 | return hex.EncodeToString(s[:]) 17 | } 18 | -------------------------------------------------------------------------------- /watchtower/wtdb/migration6/log.go: -------------------------------------------------------------------------------- 1 | package migration6 2 | 3 | import ( 4 | "github.com/btcsuite/btclog/v2" 5 | ) 6 | 7 | // log is a logger that is initialized as disabled. This means the package will 8 | // not perform any logging by default until a logger is set. 9 | var log = btclog.Disabled 10 | 11 | // UseLogger uses a specified Logger to output package logging info. 12 | func UseLogger(logger btclog.Logger) { 13 | log = logger 14 | } 15 | -------------------------------------------------------------------------------- /watchtower/wtdb/migration7/log.go: -------------------------------------------------------------------------------- 1 | package migration7 2 | 3 | import ( 4 | "github.com/btcsuite/btclog/v2" 5 | ) 6 | 7 | // log is a logger that is initialized as disabled. This means the package will 8 | // not perform any logging by default until a logger is set. 9 | var log = btclog.Disabled 10 | 11 | // UseLogger uses a specified Logger to output package logging info. 12 | func UseLogger(logger btclog.Logger) { 13 | log = logger 14 | } 15 | -------------------------------------------------------------------------------- /watchtower/wtdb/migration8/log.go: -------------------------------------------------------------------------------- 1 | package migration8 2 | 3 | import ( 4 | "github.com/btcsuite/btclog/v2" 5 | ) 6 | 7 | // log is a logger that is initialized as disabled. This means the package will 8 | // not perform any logging by default until a logger is set. 9 | var log = btclog.Disabled 10 | 11 | // UseLogger uses a specified Logger to output package logging info. 12 | func UseLogger(logger btclog.Logger) { 13 | log = logger 14 | } 15 | -------------------------------------------------------------------------------- /watchtower/wtdb/session_id.go: -------------------------------------------------------------------------------- 1 | package wtdb 2 | 3 | import ( 4 | "encoding/hex" 5 | 6 | "github.com/btcsuite/btcd/btcec/v2" 7 | ) 8 | 9 | // SessionIDSize is 33-bytes; it is a serialized, compressed public key. 10 | const SessionIDSize = 33 11 | 12 | // SessionID is created from the remote public key of a client, and serves as a 13 | // unique identifier and authentication for sending state updates. 14 | type SessionID [SessionIDSize]byte 15 | 16 | // NewSessionIDFromPubKey creates a new SessionID from a public key. 17 | func NewSessionIDFromPubKey(pubKey *btcec.PublicKey) SessionID { 18 | var sid SessionID 19 | copy(sid[:], pubKey.SerializeCompressed()) 20 | return sid 21 | } 22 | 23 | // String returns a hex encoding of the session id. 24 | func (s SessionID) String() string { 25 | return hex.EncodeToString(s[:]) 26 | } 27 | -------------------------------------------------------------------------------- /watchtower/wtserver/log.go: -------------------------------------------------------------------------------- 1 | package wtserver 2 | 3 | import ( 4 | "github.com/btcsuite/btclog/v2" 5 | "github.com/lightningnetwork/lnd/build" 6 | ) 7 | 8 | // log is a logger that is initialized with no output filters. This 9 | // means the package will not perform any logging by default until the caller 10 | // requests it. 11 | var log btclog.Logger 12 | 13 | // The default amount of logging is none. 14 | func init() { 15 | UseLogger(build.NewSubLogger("WTWR", nil)) 16 | } 17 | 18 | // DisableLog disables all library log output. Logging output is disabled 19 | // by default until UseLogger is called. 20 | func DisableLog() { 21 | UseLogger(btclog.Disabled) 22 | } 23 | 24 | // UseLogger uses a specified Logger to output package logging info. 25 | // This should be used in preference to SetLogWriter if the caller is also 26 | // using btclog. 27 | func UseLogger(logger btclog.Logger) { 28 | log = logger 29 | } 30 | --------------------------------------------------------------------------------