Add lnurlcash-go and the lnurlcash config block
Pin btcec/v2 at v2.3.3: v2.3.4 changed ecdsa.SignCompact's signature and lnd/keychain (via ln-decodepay) no longer compiles against it. The lnurlcash package gets its Config with validation and an AES-256-GCM cipher for note secrets at rest. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5.1
parent
74f5ae53a7
commit
d04669b6d6
@@ -26,6 +26,7 @@ database:
|
||||
transactions_path: "data/transactions.db"
|
||||
shop_buntdb_path: "data/shop.db"
|
||||
groupsdb_path: "data/groups.db"
|
||||
lnurlcash_path: "data/lnurlcash.db"
|
||||
generate:
|
||||
open_ai_bearer_token: "token_here"
|
||||
dalle_key: "asd"
|
||||
@@ -33,3 +34,24 @@ generate:
|
||||
worker: 2
|
||||
nostr:
|
||||
private_key: "hex private key here"
|
||||
lnurlcash: # LUD-25 bearer notes, see docs/lnurlcash/PLAN.md
|
||||
enabled: false
|
||||
mints:
|
||||
- name: 21mint
|
||||
url: https://lnurl.21mint.me
|
||||
default: true
|
||||
min_note_sat: 1
|
||||
max_note_sat: 100000
|
||||
max_outstanding_sat_per_user: 500000
|
||||
max_outstanding_notes_per_user: 200
|
||||
max_batch_size: 100
|
||||
max_batch_total_sat: 500000
|
||||
group_note_max_sat: 1000
|
||||
max_mint_fee_ppm: 20000
|
||||
auto_reclaim_days: 0
|
||||
status_poll_interval: 5m
|
||||
invoice_wait_timeout: 60s
|
||||
batch_strategy: split # or: invoices
|
||||
batch_formats: [pdf, json, csv]
|
||||
secret_encryption_key: "" # 64 hex chars, e.g. `openssl rand -hex 32`; required when enabled
|
||||
admin_telegram_id: 0 # optional: Telegram user id that receives mint alerts
|
||||
|
||||
@@ -7,13 +7,14 @@ toolchain go1.26.11
|
||||
require (
|
||||
github.com/BurntSushi/toml v0.3.1
|
||||
github.com/PuerkitoBio/goquery v1.8.0
|
||||
github.com/btcsuite/btcd/btcec/v2 v2.2.0
|
||||
github.com/btcsuite/btcd/btcec/v2 v2.5.0
|
||||
github.com/eko/gocache v1.2.0
|
||||
github.com/fiatjaf/go-lnurl v1.11.3-0.20220819192234-5c5819dd0aa7
|
||||
github.com/fiatjaf/ln-decodepay v1.1.0
|
||||
github.com/gorilla/mux v1.8.0
|
||||
github.com/imroc/req v0.3.0
|
||||
github.com/jinzhu/configor v1.2.1
|
||||
github.com/lnurlcash/lnurlcash-go v0.3.0
|
||||
github.com/makiuchi-d/gozxing v0.0.2
|
||||
github.com/nbd-wtf/go-nostr v0.13.0
|
||||
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646
|
||||
@@ -36,6 +37,14 @@ require (
|
||||
gorm.io/gorm v1.21.12
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/kcalvinalvin/anet v0.0.0-20251112173137-d8ddc1f6dbee // indirect
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
github.com/stretchr/objx v0.5.0 // indirect
|
||||
github.com/stretchr/testify v1.8.4 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/SaveTheRbtz/generic-sync-map-go v0.0.0-20220414055132-a37292614db8 // indirect
|
||||
github.com/XiaoMi/pegasus-go-client v0.0.0-20210427083443-f3b6b08bc4c2 // indirect
|
||||
@@ -44,10 +53,10 @@ require (
|
||||
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d // indirect
|
||||
github.com/andybalholm/cascadia v1.3.1 // indirect
|
||||
github.com/bradfitz/gomemcache v0.0.0-20190913173617-a41fca850d0b // indirect
|
||||
github.com/btcsuite/btcd v0.23.1 // indirect
|
||||
github.com/btcsuite/btcd/btcutil v1.1.1 // indirect
|
||||
github.com/btcsuite/btcd v0.24.2 // indirect
|
||||
github.com/btcsuite/btcd/btcutil v1.2.0 // indirect
|
||||
github.com/btcsuite/btcd/btcutil/psbt v1.1.4 // indirect
|
||||
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 // indirect
|
||||
github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0 // indirect
|
||||
github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f // indirect
|
||||
github.com/btcsuite/btcwallet v0.15.1 // indirect
|
||||
github.com/btcsuite/btcwallet/wallet/txauthor v1.2.3 // indirect
|
||||
@@ -60,8 +69,8 @@ require (
|
||||
github.com/cenkalti/backoff/v4 v4.1.0 // indirect
|
||||
github.com/cespare/xxhash/v2 v2.1.1 // indirect
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/decred/dcrd/crypto/blake256 v1.0.0 // indirect
|
||||
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect
|
||||
github.com/decred/dcrd/crypto/blake256 v1.1.0 // indirect
|
||||
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.4.0 // indirect
|
||||
github.com/decred/dcrd/lru v1.0.0 // indirect
|
||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
|
||||
github.com/go-errors/errors v1.0.1 // indirect
|
||||
@@ -107,3 +116,5 @@ require (
|
||||
)
|
||||
|
||||
// replace gopkg.in/lightningtipbot/telebot.v3 => ../telebot
|
||||
|
||||
replace github.com/btcsuite/btcd/btcec/v2 => github.com/btcsuite/btcd/btcec/v2 v2.3.3
|
||||
|
||||
@@ -104,22 +104,22 @@ github.com/btcsuite/btcd v0.22.0-beta.0.20220204213055-eaf0459ff879/go.mod h1:os
|
||||
github.com/btcsuite/btcd v0.22.0-beta.0.20220207191057-4dc4ff7963b4/go.mod h1:7alexyj/lHlOtr2PJK7L/+HDJZpcGDn/pAU98r7DY08=
|
||||
github.com/btcsuite/btcd v0.22.0-beta.0.20220316175102-8d5c75c28923/go.mod h1:taIcYprAW2g6Z9S0gGUxyR+zDwimyDMK5ePOX+iJ2ds=
|
||||
github.com/btcsuite/btcd v0.23.0/go.mod h1:0QJIIN1wwIXF/3G/m87gIwGniDMDQqjVn4SZgnFpsYY=
|
||||
github.com/btcsuite/btcd v0.23.1 h1:IB8cVQcC2X5mHbnfirLG5IZnkWYNTPlLZVrxUYSotbE=
|
||||
github.com/btcsuite/btcd v0.23.1/go.mod h1:0QJIIN1wwIXF/3G/m87gIwGniDMDQqjVn4SZgnFpsYY=
|
||||
github.com/btcsuite/btcd/btcec/v2 v2.1.0/go.mod h1:2VzYrv4Gm4apmbVVsSq5bqf1Ec8v56E48Vt0Y/umPgA=
|
||||
github.com/btcsuite/btcd/btcec/v2 v2.1.1/go.mod h1:ctjw4H1kknNJmRN4iP1R7bTQ+v3GJkZBd6mui8ZsAZE=
|
||||
github.com/btcsuite/btcd/btcec/v2 v2.1.3/go.mod h1:ctjw4H1kknNJmRN4iP1R7bTQ+v3GJkZBd6mui8ZsAZE=
|
||||
github.com/btcsuite/btcd/btcec/v2 v2.2.0 h1:fzn1qaOt32TuLjFlkzYSsBC35Q3KUjT1SwPxiMSCF5k=
|
||||
github.com/btcsuite/btcd/btcec/v2 v2.2.0/go.mod h1:U7MHm051Al6XmscBQ0BoNydpOTsFAn707034b5nY8zU=
|
||||
github.com/btcsuite/btcd v0.24.2 h1:aLmxPguqxza+4ag8R1I2nnJjSu2iFn/kqtHTIImswcY=
|
||||
github.com/btcsuite/btcd v0.24.2/go.mod h1:5C8ChTkl5ejr3WHj8tkQSCmydiMEPB0ZhQhehpq7Dgg=
|
||||
github.com/btcsuite/btcd/btcec/v2 v2.3.3 h1:6+iXlDKE8RMtKsvK0gshlXIuPbyWM/h84Ensb7o3sC0=
|
||||
github.com/btcsuite/btcd/btcec/v2 v2.3.3/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04=
|
||||
github.com/btcsuite/btcd/btcutil v1.0.0/go.mod h1:Uoxwv0pqYWhD//tfTiipkxNfdhG9UrLwaeswfjfdF0A=
|
||||
github.com/btcsuite/btcd/btcutil v1.1.0/go.mod h1:5OapHB7A2hBBWLm48mmw4MOHNJCcUBTwmWH/0Jn8VHE=
|
||||
github.com/btcsuite/btcd/btcutil v1.1.1 h1:hDcDaXiP0uEzR8Biqo2weECKqEw0uHDZ9ixIWevVQqY=
|
||||
github.com/btcsuite/btcd/btcutil v1.1.1/go.mod h1:nbKlBMNm9FGsdvKvu0essceubPiAcI57pYBNnsLAa34=
|
||||
github.com/btcsuite/btcd/btcutil v1.2.0 h1:p3+S2g3Q+7G5NOh4Ji+2UrBOrg5Z0Q4ykzShWG1Dhgs=
|
||||
github.com/btcsuite/btcd/btcutil v1.2.0/go.mod h1:/Taflm113pYjUpbWKKQEfa6XOtI/+WS8awxeMZpY75k=
|
||||
github.com/btcsuite/btcd/btcutil/psbt v1.1.4 h1:Edx4AfBn+YPam2KP5AobDitulGp4r1Oibm8oruzkMdI=
|
||||
github.com/btcsuite/btcd/btcutil/psbt v1.1.4/go.mod h1:9AyU6EQVJ9Iw9zPyNT1lcdHd6cnEZdno5wLu5FY74os=
|
||||
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.0/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc=
|
||||
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 h1:q0rUy8C/TYNBQS1+CGKw68tLOFYSNEs0TFnxxnS9+4U=
|
||||
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc=
|
||||
github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0 h1:59Kx4K6lzOW5w6nFlA0v5+lk/6sjybR934QNHSJZPTQ=
|
||||
github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc=
|
||||
github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f h1:bAs4lUbRJpnnkd9VhRV3jjAVU7DJVjMaK+IsvSeZvFo=
|
||||
github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA=
|
||||
github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg=
|
||||
@@ -210,10 +210,12 @@ github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/decred/dcrd/crypto/blake256 v1.0.0 h1:/8DMNYp9SGi5f0w7uCm6d6M4OU2rGFK09Y2A4Xv7EE0=
|
||||
github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc=
|
||||
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 h1:YLtO71vCjJRCBcrPMtQ9nqBsqpA1m5sE92cU+pd5Mcc=
|
||||
github.com/decred/dcrd/crypto/blake256 v1.1.0 h1:zPMNGQCm0g4QTY27fOCorQW7EryeQ/U0x++OzVrdms8=
|
||||
github.com/decred/dcrd/crypto/blake256 v1.1.0/go.mod h1:2OfgNZ5wDpcsFmHmCK5gZTPcCXqlm2ArzUIkw9czNJo=
|
||||
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs=
|
||||
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.4.0 h1:NMZiJj8QnKe1LgsbDayM4UoHwbvwDRwnI3hwNaAHRnc=
|
||||
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.4.0/go.mod h1:ZXNYxsqcloTdSy/rNShjYzMhyjf0LaoftYK0p+A3h40=
|
||||
github.com/decred/dcrd/lru v1.0.0 h1:Kbsb1SFDsIlaupWPwsPp+dkxiBY1frcS07PCPgotKz8=
|
||||
github.com/decred/dcrd/lru v1.0.0/go.mod h1:mxKOwFd7lFjN2GZYsiz/ecgqR6kkYAl+0pz0tEMk218=
|
||||
github.com/dgraph-io/ristretto v0.0.3 h1:jh22xisGBjrEVnRZ1DVTpBVQm0Xndu8sMl0CWDzSIBI=
|
||||
@@ -553,6 +555,8 @@ github.com/juju/version/v2 v2.0.0-20211007103408-2e8da085dc23/go.mod h1:Ljlbryh9
|
||||
github.com/julienschmidt/httprouter v1.1.1-0.20151013225520-77a895ad01eb/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
|
||||
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
|
||||
github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM=
|
||||
github.com/kcalvinalvin/anet v0.0.0-20251112173137-d8ddc1f6dbee h1:FPP9HDkBbPyniu+u7FHZg+kKFX1WW0gxOGteJ0h3AJk=
|
||||
github.com/kcalvinalvin/anet v0.0.0-20251112173137-d8ddc1f6dbee/go.mod h1:N6sz6HwJAenJ6d+/xmSl0ikfV05ZrVGmjt1ryy/WOtE=
|
||||
github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
|
||||
github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00=
|
||||
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
|
||||
@@ -629,6 +633,8 @@ github.com/lightningnetwork/lnd/tor v1.0.1 h1:A11FrpU0Y//g+fA827W4VnjOeoIvExONdc
|
||||
github.com/lightningnetwork/lnd/tor v1.0.1/go.mod h1:RDtaAdwfAm+ONuPYwUhNIH1RAvKPv+75lHPOegUcz64=
|
||||
github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM=
|
||||
github.com/lightstep/lightstep-tracer-go v0.18.1/go.mod h1:jlF1pusYV4pidLvZ+XD0UBX0ZE6WURAspgAczcDHrL4=
|
||||
github.com/lnurlcash/lnurlcash-go v0.3.0 h1:12LUZJXqvyDfvZ1uWbk1kFh9le7vOIMKiraQiUqvZ1A=
|
||||
github.com/lnurlcash/lnurlcash-go v0.3.0/go.mod h1:tBFpb7fqLeX0zcLqjNqqa9R9ogH2q5QM8m/rUZMFz1s=
|
||||
github.com/ltcsuite/ltcd v0.0.0-20190101042124-f37f8bf35796 h1:sjOGyegMIhvgfq5oaue6Td+hxZuf3tDC8lAPrFldqFw=
|
||||
github.com/ltcsuite/ltcd v0.0.0-20190101042124-f37f8bf35796/go.mod h1:3p7ZTf9V1sNPI5H8P3NkTFF4LuwMdPl2DodF60qAKqY=
|
||||
github.com/ltcsuite/ltcutil v0.0.0-20181217130922-17f3b04680b6/go.mod h1:8Vg/LTOO0KYa/vlHWJ6XZAevPQThGH5sufO0Hrou/lA=
|
||||
@@ -855,8 +861,10 @@ github.com/streadway/amqp v0.0.0-20190827072141-edfb9018d271/go.mod h1:AZpEONHx3
|
||||
github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5JnDBl6z3cMAg/SywNDC5ABu5ApDIw6lUbRmI=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.2.0 h1:Hbg2NidpLE8veEBkEZTL3CvlkUIVzuU9jDplZO54c48=
|
||||
github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
|
||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||
github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c=
|
||||
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
||||
github.com/stretchr/testify v0.0.0-20151208002404-e3a8ff8ce365/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
@@ -864,8 +872,10 @@ github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81P
|
||||
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
|
||||
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY=
|
||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
|
||||
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
|
||||
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY=
|
||||
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc=
|
||||
@@ -1030,7 +1040,6 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0
|
||||
golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
|
||||
golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM=
|
||||
golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU=
|
||||
golang.org/x/exp v0.0.0-20220426173459-3bcf042a4bf5/go.mod h1:lgLbSvA5ygNOMpwM/9anMpWVlVJ7Z+cHWq/eFuinpGE=
|
||||
golang.org/x/exp v0.0.0-20221106115401-f9659909a136 h1:Fq7F/w7MAa1KJ5bt2aJ62ihqp9HDcRuyILskkpIAurw=
|
||||
golang.org/x/exp v0.0.0-20221106115401-f9659909a136/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc=
|
||||
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
|
||||
@@ -1057,7 +1066,6 @@ golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro=
|
||||
golang.org/x/mod v0.6.0-dev.0.20211013180041-c96bc1413d57/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY=
|
||||
golang.org/x/net v0.0.0-20170114055629-f2499483f923/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180406214816-61147c48b25b/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
@@ -1284,7 +1292,6 @@ golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4f
|
||||
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||
golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
||||
golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
||||
golang.org/x/tools v0.1.8-0.20211029000441-d6a9af8af023/go.mod h1:nABZi5QlRsZVlzPpHl034qft6wpY4eDcsTt5AaioBiU=
|
||||
golang.org/x/tools v0.1.8/go.mod h1:nABZi5QlRsZVlzPpHl034qft6wpY4eDcsTt5AaioBiU=
|
||||
golang.org/x/xerrors v0.0.0-20190410155217-1f06c39b4373/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
@@ -1437,8 +1444,9 @@ gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
||||
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo=
|
||||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gorm.io/driver/sqlite v1.1.4 h1:PDzwYE+sI6De2+mxAneV9Xs11+ZyKV6oxD3wDGkaNvM=
|
||||
gorm.io/driver/sqlite v1.1.4/go.mod h1:mJCeTFr7+crvS+TRnWc5Z3UvwxUN1BGBLMrf5LA9DYw=
|
||||
gorm.io/gorm v1.20.7/go.mod h1:0HFTzE/SqkGTzK6TlDPPQbAYCluiVvhzoA1+aVyzenw=
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/LightningTipBot/LightningTipBot/internal/lnurlcash"
|
||||
"github.com/jinzhu/configor"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
@@ -17,6 +18,8 @@ var Configuration = struct {
|
||||
Lnbits LnbitsConfiguration `yaml:"lnbits"`
|
||||
Generate GenerateConfiguration `yaml:"generate"`
|
||||
Nostr NostrConfiguration `yaml:"nostr"`
|
||||
// LNURLCash is the optional LUD-25 bearer note feature (see docs/lnurlcash).
|
||||
LNURLCash lnurlcash.Config `yaml:"lnurlcash"`
|
||||
}{}
|
||||
|
||||
type NostrConfiguration struct {
|
||||
@@ -58,6 +61,8 @@ type DatabaseConfiguration struct {
|
||||
BuntDbPath string `yaml:"buntdb_path"`
|
||||
TransactionsPath string `yaml:"transactions_path"`
|
||||
GroupsDbPath string `yaml:"groupsdb_path"`
|
||||
// LNURLCashPath is the sqlite file holding LNURLcash notes, batches and mints.
|
||||
LNURLCashPath string `yaml:"lnurlcash_path"`
|
||||
}
|
||||
|
||||
type LnbitsConfiguration struct {
|
||||
@@ -96,6 +101,18 @@ func init() {
|
||||
return
|
||||
}
|
||||
checkLnbitsConfiguration()
|
||||
checkLNURLCashConfiguration()
|
||||
}
|
||||
|
||||
// checkLNURLCashConfiguration refuses to start with a broken lnurlcash block:
|
||||
// a half-configured note feature would mint money it cannot keep track of.
|
||||
func checkLNURLCashConfiguration() {
|
||||
if err := Configuration.LNURLCash.Validate(); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if Configuration.LNURLCash.Enabled && Configuration.Database.LNURLCashPath == "" {
|
||||
Configuration.Database.LNURLCashPath = "data/lnurlcash.db"
|
||||
}
|
||||
}
|
||||
|
||||
// isTestBinary reports whether the process is a go test binary.
|
||||
|
||||
@@ -0,0 +1,186 @@
|
||||
// Package lnurlcash implements LNURLcash (LUD-25) bearer notes for the bot:
|
||||
// notes are minted at admin-listed mints, their secrets are stored encrypted,
|
||||
// and the balance stays in LNbits. Amounts inside this package are int64
|
||||
// millisatoshi everywhere.
|
||||
package lnurlcash
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
lnurlcash "github.com/lnurlcash/lnurlcash-go"
|
||||
)
|
||||
|
||||
// MintConfig is one admin-listed mint.
|
||||
type MintConfig struct {
|
||||
Name string `yaml:"name"`
|
||||
URL string `yaml:"url"`
|
||||
Default bool `yaml:"default"`
|
||||
}
|
||||
|
||||
// Config is the `lnurlcash:` block of config.yaml.
|
||||
type Config struct {
|
||||
Enabled bool `yaml:"enabled"`
|
||||
Mints []MintConfig `yaml:"mints"`
|
||||
MinNoteSat int64 `yaml:"min_note_sat"`
|
||||
MaxNoteSat int64 `yaml:"max_note_sat"`
|
||||
MaxOutstandingSatPerUser int64 `yaml:"max_outstanding_sat_per_user"`
|
||||
MaxOutstandingNotesPerUser int64 `yaml:"max_outstanding_notes_per_user"`
|
||||
MaxBatchSize int64 `yaml:"max_batch_size"`
|
||||
MaxBatchTotalSat int64 `yaml:"max_batch_total_sat"`
|
||||
GroupNoteMaxSat int64 `yaml:"group_note_max_sat"`
|
||||
MaxMintFeePpm int64 `yaml:"max_mint_fee_ppm"`
|
||||
AutoReclaimDays int `yaml:"auto_reclaim_days"`
|
||||
StatusPollInterval time.Duration `yaml:"status_poll_interval"`
|
||||
InvoiceWaitTimeout time.Duration `yaml:"invoice_wait_timeout"`
|
||||
BatchStrategy string `yaml:"batch_strategy"`
|
||||
BatchFormats []string `yaml:"batch_formats"`
|
||||
SecretEncryptionKey string `yaml:"secret_encryption_key"`
|
||||
// AdminTelegramID receives mint alerts when set; otherwise alerts are logged only.
|
||||
AdminTelegramID int64 `yaml:"admin_telegram_id"`
|
||||
}
|
||||
|
||||
const (
|
||||
StrategySplit = "split"
|
||||
StrategyInvoices = "invoices"
|
||||
)
|
||||
|
||||
var knownFormats = map[string]bool{"pdf": true, "json": true, "csv": true}
|
||||
|
||||
// Normalize fills defaults for zero values. It is safe to call more than once.
|
||||
func (c *Config) Normalize() {
|
||||
if c.MinNoteSat <= 0 {
|
||||
c.MinNoteSat = 1
|
||||
}
|
||||
if c.MaxNoteSat <= 0 {
|
||||
c.MaxNoteSat = 100_000
|
||||
}
|
||||
if c.MaxOutstandingSatPerUser <= 0 {
|
||||
c.MaxOutstandingSatPerUser = 500_000
|
||||
}
|
||||
if c.MaxOutstandingNotesPerUser <= 0 {
|
||||
c.MaxOutstandingNotesPerUser = 200
|
||||
}
|
||||
if c.MaxBatchSize <= 0 {
|
||||
c.MaxBatchSize = 100
|
||||
}
|
||||
if c.MaxBatchTotalSat <= 0 {
|
||||
c.MaxBatchTotalSat = 500_000
|
||||
}
|
||||
if c.GroupNoteMaxSat <= 0 {
|
||||
c.GroupNoteMaxSat = 1000
|
||||
}
|
||||
if c.MaxMintFeePpm <= 0 {
|
||||
c.MaxMintFeePpm = 20_000
|
||||
}
|
||||
if c.StatusPollInterval <= 0 {
|
||||
c.StatusPollInterval = 5 * time.Minute
|
||||
}
|
||||
if c.InvoiceWaitTimeout <= 0 {
|
||||
c.InvoiceWaitTimeout = 60 * time.Second
|
||||
}
|
||||
if c.BatchStrategy == "" {
|
||||
c.BatchStrategy = StrategySplit
|
||||
}
|
||||
if len(c.BatchFormats) == 0 {
|
||||
c.BatchFormats = []string{"pdf", "json", "csv"}
|
||||
}
|
||||
}
|
||||
|
||||
// Validate checks the block. It only complains when the feature is enabled.
|
||||
func (c *Config) Validate() error {
|
||||
c.Normalize()
|
||||
if !c.Enabled {
|
||||
return nil
|
||||
}
|
||||
if len(c.Mints) == 0 {
|
||||
return fmt.Errorf("lnurlcash: at least one mint is required")
|
||||
}
|
||||
defaults := 0
|
||||
seen := map[string]bool{}
|
||||
for i, m := range c.Mints {
|
||||
if strings.TrimSpace(m.Name) == "" {
|
||||
return fmt.Errorf("lnurlcash: mint %d has no name", i)
|
||||
}
|
||||
if seen[m.Name] {
|
||||
return fmt.Errorf("lnurlcash: mint name %q is listed twice", m.Name)
|
||||
}
|
||||
seen[m.Name] = true
|
||||
if ResolveMintURL(m.URL) == "" {
|
||||
return fmt.Errorf("lnurlcash: mint %q has an invalid url %q (https URL, lightning address or bare domain)", m.Name, m.URL)
|
||||
}
|
||||
if m.Default {
|
||||
defaults++
|
||||
}
|
||||
}
|
||||
if defaults != 1 {
|
||||
return fmt.Errorf("lnurlcash: exactly one mint must be marked default (found %d)", defaults)
|
||||
}
|
||||
if c.BatchStrategy != StrategySplit && c.BatchStrategy != StrategyInvoices {
|
||||
return fmt.Errorf("lnurlcash: batch_strategy must be %q or %q", StrategySplit, StrategyInvoices)
|
||||
}
|
||||
for _, f := range c.BatchFormats {
|
||||
if !knownFormats[f] {
|
||||
return fmt.Errorf("lnurlcash: unknown batch format %q", f)
|
||||
}
|
||||
}
|
||||
if c.MinNoteSat > c.MaxNoteSat {
|
||||
return fmt.Errorf("lnurlcash: min_note_sat is above max_note_sat")
|
||||
}
|
||||
if c.MaxMintFeePpm >= 1_000_000 {
|
||||
return fmt.Errorf("lnurlcash: max_mint_fee_ppm must be below 1000000")
|
||||
}
|
||||
key, err := hex.DecodeString(strings.TrimSpace(c.SecretEncryptionKey))
|
||||
if err != nil || len(key) != 32 {
|
||||
return fmt.Errorf("lnurlcash: secret_encryption_key must be 32 bytes as 64 hex characters (generate one with `openssl rand -hex 32`)")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// DefaultMint returns the mint marked default, or the first one.
|
||||
func (c *Config) DefaultMint() *MintConfig {
|
||||
for i := range c.Mints {
|
||||
if c.Mints[i].Default {
|
||||
return &c.Mints[i]
|
||||
}
|
||||
}
|
||||
if len(c.Mints) > 0 {
|
||||
return &c.Mints[0]
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// HasFormat reports whether a batch export format is enabled.
|
||||
func (c *Config) HasFormat(format string) bool {
|
||||
for _, f := range c.BatchFormats {
|
||||
if f == format {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// ResolveMintURL turns a configured mint reference into its payRequest URL.
|
||||
// Accepted forms: a bare domain or lightning address (lnurlcash-go's
|
||||
// ResolveMintInput), a bech32 LNURL, a payRequest URL, or a plain https base
|
||||
// URL of a mint, which uses lnurl-mint's default "mint" identifier.
|
||||
func ResolveMintURL(input string) string {
|
||||
trimmed := strings.TrimSpace(input)
|
||||
lower := strings.ToLower(trimmed)
|
||||
if strings.HasPrefix(lower, "https://") || strings.HasPrefix(lower, "http://") {
|
||||
if !lnurlcash.IsAllowedServiceURL(trimmed) {
|
||||
return ""
|
||||
}
|
||||
if strings.Contains(trimmed, "/.well-known/lnurlp/") {
|
||||
return trimmed
|
||||
}
|
||||
host := strings.TrimRight(strings.SplitN(trimmed[strings.Index(trimmed, "://")+3:], "/", 2)[0], "/")
|
||||
if host == "" {
|
||||
return ""
|
||||
}
|
||||
return lnurlcash.ResolveMintInput("mint@" + host)
|
||||
}
|
||||
return lnurlcash.ResolveMintInput(trimmed)
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package lnurlcash
|
||||
|
||||
import (
|
||||
"crypto/aes"
|
||||
"crypto/cipher"
|
||||
"crypto/rand"
|
||||
"encoding/hex"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Cipher seals note secrets at rest with AES-256-GCM. The ciphertext is
|
||||
// nonce || sealed, so every call to Seal gives a different value for the
|
||||
// same secret.
|
||||
type Cipher struct {
|
||||
aead cipher.AEAD
|
||||
}
|
||||
|
||||
// NewCipher takes the key as 64 hex characters.
|
||||
func NewCipher(hexKey string) (*Cipher, error) {
|
||||
key, err := hex.DecodeString(strings.TrimSpace(hexKey))
|
||||
if err != nil || len(key) != 32 {
|
||||
return nil, errors.New("lnurlcash: encryption key must be 32 bytes of hex")
|
||||
}
|
||||
block, err := aes.NewCipher(key)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
aead, err := cipher.NewGCM(block)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &Cipher{aead: aead}, nil
|
||||
}
|
||||
|
||||
// Seal encrypts a secret.
|
||||
func (c *Cipher) Seal(plain string) ([]byte, error) {
|
||||
if c == nil {
|
||||
return nil, errors.New("lnurlcash: no cipher configured")
|
||||
}
|
||||
nonce := make([]byte, c.aead.NonceSize())
|
||||
if _, err := io.ReadFull(rand.Reader, nonce); err != nil {
|
||||
return nil, fmt.Errorf("lnurlcash: could not draw a nonce: %w", err)
|
||||
}
|
||||
return append(nonce, c.aead.Seal(nil, nonce, []byte(plain), nil)...), nil
|
||||
}
|
||||
|
||||
// Open decrypts a value produced by Seal.
|
||||
func (c *Cipher) Open(sealed []byte) (string, error) {
|
||||
if c == nil {
|
||||
return "", errors.New("lnurlcash: no cipher configured")
|
||||
}
|
||||
n := c.aead.NonceSize()
|
||||
if len(sealed) < n+c.aead.Overhead() {
|
||||
return "", errors.New("lnurlcash: sealed secret is too short")
|
||||
}
|
||||
plain, err := c.aead.Open(nil, sealed[:n], sealed[n:], nil)
|
||||
if err != nil {
|
||||
return "", errors.New("lnurlcash: sealed secret does not open with this key")
|
||||
}
|
||||
return string(plain), nil
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
package lnurlcash
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
const testKey = "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f"
|
||||
|
||||
func TestCipherRoundTrip(t *testing.T) {
|
||||
c, err := NewCipher(testKey)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
secret := strings.Repeat("ab", 32)
|
||||
sealed, err := c.Seal(secret)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
again, err := c.Seal(secret)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if string(sealed) == string(again) {
|
||||
t.Fatal("two seals of the same secret must differ (random nonce)")
|
||||
}
|
||||
got, err := c.Open(sealed)
|
||||
if err != nil || got != secret {
|
||||
t.Fatalf("open: %v %q", err, got)
|
||||
}
|
||||
sealed[len(sealed)-1] ^= 1
|
||||
if _, err := c.Open(sealed); err == nil {
|
||||
t.Fatal("tampered ciphertext must not open")
|
||||
}
|
||||
other, _ := NewCipher(strings.Repeat("ff", 32))
|
||||
if _, err := other.Open(sealed[:len(sealed)]); err == nil {
|
||||
t.Fatal("wrong key must not open")
|
||||
}
|
||||
if _, err := NewCipher("abc"); err == nil {
|
||||
t.Fatal("short key must be refused")
|
||||
}
|
||||
}
|
||||
|
||||
func TestConfigValidate(t *testing.T) {
|
||||
c := Config{}
|
||||
if err := c.Validate(); err != nil {
|
||||
t.Fatalf("disabled config must validate: %v", err)
|
||||
}
|
||||
if c.StatusPollInterval == 0 || c.BatchStrategy != StrategySplit || len(c.BatchFormats) != 3 {
|
||||
t.Fatal("defaults not applied")
|
||||
}
|
||||
c = Config{Enabled: true}
|
||||
if err := c.Validate(); err == nil {
|
||||
t.Fatal("enabled without mints must fail")
|
||||
}
|
||||
c.Mints = []MintConfig{{Name: "21mint", URL: "https://lnurl.21mint.me", Default: true}}
|
||||
if err := c.Validate(); err == nil || !strings.Contains(err.Error(), "secret_encryption_key") {
|
||||
t.Fatalf("missing key must fail: %v", err)
|
||||
}
|
||||
c.SecretEncryptionKey = testKey
|
||||
if err := c.Validate(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
c.Mints = append(c.Mints, MintConfig{Name: "other", URL: "http://insecure.example", Default: true})
|
||||
if err := c.Validate(); err == nil {
|
||||
t.Fatal("http clearnet url and two defaults must fail")
|
||||
}
|
||||
c.Mints[1] = MintConfig{Name: "other", URL: "mint@other.example"}
|
||||
if err := c.Validate(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if c.DefaultMint().Name != "21mint" {
|
||||
t.Fatal("wrong default mint")
|
||||
}
|
||||
c.BatchFormats = []string{"docx"}
|
||||
if err := c.Validate(); err == nil {
|
||||
t.Fatal("unknown format must fail")
|
||||
}
|
||||
}
|
||||
|
||||
func TestResolveMintURL(t *testing.T) {
|
||||
cases := map[string]string{
|
||||
"https://lnurl.21mint.me": "https://lnurl.21mint.me/.well-known/lnurlp/mint",
|
||||
"https://lnurl.21mint.me/": "https://lnurl.21mint.me/.well-known/lnurlp/mint",
|
||||
"https://lnurl.21mint.me/.well-known/lnurlp/mint": "https://lnurl.21mint.me/.well-known/lnurlp/mint",
|
||||
"lnurl.21mint.me": "https://lnurl.21mint.me/.well-known/lnurlp/mint",
|
||||
"mint@lnurl.21mint.me": "https://lnurl.21mint.me/.well-known/lnurlp/mint",
|
||||
"http://lnurl.21mint.me": "",
|
||||
"http://localhost:3338": "http://localhost:3338/.well-known/lnurlp/mint",
|
||||
"": "",
|
||||
}
|
||||
for in, want := range cases {
|
||||
if got := ResolveMintURL(in); got != want {
|
||||
t.Errorf("%q: got %q want %q", in, got, want)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user