Skip to content

Commit

Permalink
feat: pro config option
Browse files Browse the repository at this point in the history
  • Loading branch information
jackstar12 committed Feb 3, 2025
1 parent fac5e57 commit 6911bf2
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
5 changes: 5 additions & 0 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ type Config struct {

Proxy string `long:"proxy" description:"Proxy URL to use for all Boltz API requests"`

Pro bool `long:"pro" description:"Use boltz pro API"`
ReferralId string

MaxZeroConfAmount *uint64 `long:"max-zeroconf-amount" description:"Maximum amount of sats to accept 0-conf"`
Expand Down Expand Up @@ -247,6 +248,10 @@ func LoadConfig(dataDir string) (*Config, error) {
cfg.RPC.AdminMacaroonPath = utils.ExpandDefaultPath(macaroonDir, cfg.RPC.AdminMacaroonPath, "admin.macaroon")
cfg.RPC.ReadonlyMacaroonPath = utils.ExpandDefaultPath(macaroonDir, cfg.RPC.ReadonlyMacaroonPath, "readonly.macaroon")

if cfg.Pro {
cfg.ReferralId = "pro"
}

createDirIfNotExists(cfg.DataDir)
createDirIfNotExists(macaroonDir)

Expand Down
2 changes: 1 addition & 1 deletion internal/rpcserver/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ func initBoltz(cfg *config.Config, network *boltz.Network) (*boltz.Api, error) {
logger.Info("Using configured Boltz endpoint: " + boltzUrl)
}

boltzApi := &boltz.Api{URL: boltzUrl}
boltzApi := &boltz.Api{URL: boltzUrl, Referral: cfg.ReferralId}
if cfg.Proxy != "" {
proxy, err := url.Parse(cfg.Proxy)
if err != nil {
Expand Down
13 changes: 10 additions & 3 deletions pkg/boltz/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ import (
)

type Api struct {
URL string
Client http.Client
URL string
Client http.Client
Referral string

DisablePartialSignatures bool
}
Expand Down Expand Up @@ -713,7 +714,13 @@ func (boltz *Api) FetchBolt12Invoice(offer string, amountSat uint64) (string, er
}

func (boltz *Api) sendGetRequest(endpoint string, response interface{}) error {
res, err := boltz.Client.Get(boltz.URL + endpoint)
request, err := http.NewRequest("GET", boltz.URL+endpoint, nil)
if err != nil {
return err
}
request.Header.Set("Referral", boltz.Referral)

res, err := boltz.Client.Do(request)

if err != nil {
return err
Expand Down

0 comments on commit 6911bf2

Please sign in to comment.