Skip to content

Commit 95e53f6

Browse files
committed
multi: add noop-htlcs daemon configuration
This commit adds a new daemon configuration option that controls whether NoOp HTLCs are produced over the tap channels.
1 parent 62a1709 commit 95e53f6

File tree

6 files changed

+47
-5
lines changed

6 files changed

+47
-5
lines changed

rfq/manager.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,10 @@ type ManagerCfg struct {
123123
// messages (this means that the price oracle will not be queried).
124124
SkipAcceptQuotePriceCheck bool
125125

126+
// NoOpHTLCs is a boolean indicating whether the daemon configuration
127+
// wants us to produce NoOp HTLCs.
128+
NoOpHTLCs bool
129+
126130
// ErrChan is the main error channel which will be used to report back
127131
// critical errors to the main server.
128132
ErrChan chan<- error
@@ -244,6 +248,7 @@ func (m *Manager) startSubsystems(ctx context.Context) error {
244248
HtlcSubscriber: m.cfg.HtlcSubscriber,
245249
AcceptHtlcEvents: m.acceptHtlcEvents,
246250
SpecifierChecker: m.AssetMatchesSpecifier,
251+
NoOpHTLCs: m.cfg.NoOpHTLCs,
247252
})
248253
if err != nil {
249254
return fmt.Errorf("error initializing RFQ order handler: %w",

rfq/order.go

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,13 +121,17 @@ type AssetSalePolicy struct {
121121
// that they carry.
122122
htlcToAmt map[models.CircuitKey]lnwire.MilliSatoshi
123123

124+
// NoOpHTLCs is a boolean indicating whether the daemon configuration
125+
// wants us to produce NoOp HTLCs.
126+
NoOpHTLCs bool
127+
124128
// expiry is the policy's expiry unix timestamp after which the policy
125129
// is no longer valid.
126130
expiry uint64
127131
}
128132

129133
// NewAssetSalePolicy creates a new asset sale policy.
130-
func NewAssetSalePolicy(quote rfqmsg.BuyAccept) *AssetSalePolicy {
134+
func NewAssetSalePolicy(quote rfqmsg.BuyAccept, noop bool) *AssetSalePolicy {
131135
htlcToAmtMap := make(map[models.CircuitKey]lnwire.MilliSatoshi)
132136

133137
return &AssetSalePolicy{
@@ -137,6 +141,7 @@ func NewAssetSalePolicy(quote rfqmsg.BuyAccept) *AssetSalePolicy {
137141
AskAssetRate: quote.AssetRate.Rate,
138142
expiry: uint64(quote.AssetRate.Expiry.Unix()),
139143
htlcToAmt: htlcToAmtMap,
144+
NoOpHTLCs: noop,
140145
}
141146
}
142147

@@ -288,7 +293,9 @@ func (c *AssetSalePolicy) GenerateInterceptorResponse(
288293
// We are about to create an outgoing HTLC that carries assets. Let's
289294
// set the noop flag in order to eventually only settle the assets but
290295
// never settle the sats anchor amount that will carry them.
291-
htlcRecord.SetNoopAdd(rfqmsg.UseNoOpHTLCs)
296+
if c.NoOpHTLCs {
297+
htlcRecord.SetNoopAdd(rfqmsg.UseNoOpHTLCs)
298+
}
292299

293300
customRecords, err := lnwire.ParseCustomRecords(htlcRecord.Bytes())
294301
if err != nil {
@@ -675,6 +682,10 @@ type OrderHandlerCfg struct {
675682
// SpecifierChecker is an interface that contains methods for
676683
// checking certain properties related to asset specifiers.
677684
SpecifierChecker rfqmsg.SpecifierChecker
685+
686+
// NoOpHTLCs is a boolean indicating whether the daemon configuration
687+
// wants us to produce NoOp HTLCs.
688+
NoOpHTLCs bool
678689
}
679690

680691
// OrderHandler orchestrates management of accepted quote bundles. It monitors
@@ -929,7 +940,7 @@ func (h *OrderHandler) RegisterAssetSalePolicy(buyAccept rfqmsg.BuyAccept) {
929940
log.Debugf("Order handler is registering an asset sale policy given a "+
930941
"buy accept message: %s", buyAccept.String())
931942

932-
policy := NewAssetSalePolicy(buyAccept)
943+
policy := NewAssetSalePolicy(buyAccept, h.cfg.NoOpHTLCs)
933944
h.policies.Store(policy.AcceptedQuoteId.Scid(), policy)
934945
}
935946

sample-tapd.conf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,12 @@
403403
; creating an address
404404
; address.disable-syncer=false
405405

406+
[channel]
407+
408+
; If set, all channels will default to using NoOp HTLCs. This type of HTLC will
409+
; only move assets over the channel, but not any satoshi balance
410+
; channel.noop-htlcs=false
411+
406412
[prometheus]
407413

408414
; If true prometheus metrics will be exported

tapcfg/config.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,10 @@ type ChainConfig struct {
221221
SigNetChallenge string `long:"signetchallenge" description:"Connect to a custom signet network defined by this challenge instead of using the global default signet test network -- Can be specified multiple times"`
222222
}
223223

224+
type ChannelConfig struct {
225+
NoopHTLCs bool `long:"noop-htlcs" description:"toggles the use of noop HTLCs over tap channels"`
226+
}
227+
224228
// RpcConfig houses the set of config options that affect how clients connect
225229
// to the main RPC server.
226230
type RpcConfig struct {
@@ -357,6 +361,8 @@ type Config struct {
357361

358362
AddrBook *AddrBookConfig `group:"address" namespace:"address"`
359363

364+
Channel *ChannelConfig `group:"channel" namespace:"channel"`
365+
360366
Prometheus monitoring.PrometheusConfig `group:"prometheus" namespace:"prometheus"`
361367

362368
Experimental *ExperimentalConfig `group:"experimental" namespace:"experimental"`
@@ -464,6 +470,9 @@ func DefaultConfig() Config {
464470
AddrBook: &AddrBookConfig{
465471
DisableSyncer: false,
466472
},
473+
Channel: &ChannelConfig{
474+
NoopHTLCs: false,
475+
},
467476
Experimental: &ExperimentalConfig{
468477
Rfq: rfq.CliConfig{
469478
AcceptPriceDeviationPpm: rfq.DefaultAcceptPriceDeviationPpm,

tapcfg/server.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,7 @@ func genServerConfig(cfg *Config, cfgLogger btclog.Logger,
469469
AcceptPriceDeviationPpm: rfqCfg.AcceptPriceDeviationPpm,
470470
// nolint: lll
471471
SkipAcceptQuotePriceCheck: rfqCfg.SkipAcceptQuotePriceCheck,
472+
NoOpHTLCs: cfg.Channel.NoopHTLCs,
472473
ErrChan: mainErrChan,
473474
},
474475
)
@@ -539,6 +540,7 @@ func genServerConfig(cfg *Config, cfgLogger btclog.Logger,
539540
&tapchannel.TrafficShaperConfig{
540541
ChainParams: &tapChainParams,
541542
RfqManager: rfqManager,
543+
NoopHTLCs: cfg.Channel.NoopHTLCs,
542544
},
543545
)
544546
auxInvoiceManager := tapchannel.NewAuxInvoiceManager(

tapchannel/aux_traffic_shaper.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ type TrafficShaperConfig struct {
2929
ChainParams *address.ChainParams
3030

3131
RfqManager *rfq.Manager
32+
33+
// NoOpHTLCs is a boolean indicating whether the daemon configuration
34+
// wants us to produce NoOp HTLCs.
35+
NoopHTLCs bool
3236
}
3337

3438
// AuxTrafficShaper is a Taproot Asset auxiliary traffic shaper that can be used
@@ -474,7 +478,10 @@ func (s *AuxTrafficShaper) ProduceHtlcExtraData(totalAmount lnwire.MilliSatoshi,
474478
log.Tracef("Already have asset amount (sum %d) in HTLC, not "+
475479
"producing extra data", htlc.Amounts.Val.Sum())
476480

477-
htlc.SetNoopAdd(rfqmsg.UseNoOpHTLCs)
481+
if s.cfg.NoopHTLCs {
482+
htlc.SetNoopAdd(rfqmsg.UseNoOpHTLCs)
483+
}
484+
478485
updatedRecords, err := htlc.ToCustomRecords()
479486
if err != nil {
480487
return 0, nil, err
@@ -580,7 +587,9 @@ func (s *AuxTrafficShaper) ProduceHtlcExtraData(totalAmount lnwire.MilliSatoshi,
580587
// Now we set the flag that marks this HTLC as a noop_add, which means
581588
// that the above dust will eventually return to us. This means that
582589
// only the assets will be sent and not any btc balance.
583-
htlc.SetNoopAdd(rfqmsg.UseNoOpHTLCs)
590+
if s.cfg.NoopHTLCs {
591+
htlc.SetNoopAdd(rfqmsg.UseNoOpHTLCs)
592+
}
584593

585594
updatedRecords, err := htlc.ToCustomRecords()
586595
if err != nil {

0 commit comments

Comments
 (0)