Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: pro config option #385

Merged
merged 2 commits into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading