Fix crashes and the dropped certificate in satdress

Transaction.Send dereferenced a nil error when logging a failed DB save
after a successful transfer. satdress.SetupHttpClient type-asserted a
nil Transport for local nodes. The /node command shadowed the cert
variable, so a supplied certificate was never used and TLS verification
was always disabled for LND nodes.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
Michilis
2026-11-13 20:41:39 +00:00
co-authored by Claude Fable 5.1
parent afd1050e57
commit 86b7a8f7bc
3 changed files with 8 additions and 3 deletions
+6 -1
View File
@@ -68,8 +68,10 @@ type CheckInvoiceParams struct {
func SetupHttpClient(useProxy bool, cert []byte) (*http.Client, error) {
var client *http.Client
if !useProxy {
// a nil Transport would make the TLS setup below panic
client = &http.Client{
Timeout: 10 * time.Second,
Timeout: 10 * time.Second,
Transport: http.DefaultTransport.(*http.Transport).Clone(),
}
} else {
var err error
@@ -79,6 +81,9 @@ func SetupHttpClient(useProxy bool, cert []byte) (*http.Client, error) {
}
}
if client.Transport == nil {
client.Transport = http.DefaultTransport.(*http.Transport).Clone()
}
// use a cert or skip TLS verification?
if len(cert) > 0 {
caCertPool := x509.NewCertPool()
+1 -1
View File
@@ -60,7 +60,7 @@ func parseUserSettingInput(ctx intercept.Context, m *tb.Message) (satdress.Backe
var pem []byte
if splitlen == 6 {
cert := splits[5]
pem := parseCertificateToPem(cert)
pem = parseCertificateToPem(cert)
if len(pem) < 1 {
return params, fmt.Errorf("certificate has invalid format")
}
+1 -1
View File
@@ -78,7 +78,7 @@ func (t *Transaction) Send() (success bool, err error) {
// save transaction to db
tx := t.Bot.DB.Transactions.Save(t)
if tx.Error != nil {
errMsg := fmt.Sprintf("Error: Could not log transaction: %s", err.Error())
errMsg := fmt.Sprintf("Error: Could not log transaction: %s", tx.Error.Error())
log.Errorln(errMsg)
}
return success, err