@@ -16,6 +16,7 @@ import (
1616 proxy "github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
1717 "github.com/lightninglabs/lndclient"
1818 "github.com/lightninglabs/loop"
19+ "github.com/lightninglabs/loop/assets"
1920 "github.com/lightninglabs/loop/instantout"
2021 "github.com/lightninglabs/loop/instantout/reservation"
2122 "github.com/lightninglabs/loop/loopd/perms"
@@ -28,6 +29,7 @@ import (
2829 "github.com/lightninglabs/loop/staticaddr/withdraw"
2930 loop_swaprpc "github.com/lightninglabs/loop/swapserverrpc"
3031 "github.com/lightninglabs/loop/sweepbatcher"
32+ "github.com/lightninglabs/taproot-assets/taprpc"
3133 "github.com/lightningnetwork/lnd/clock"
3234 "github.com/lightningnetwork/lnd/lntypes"
3335 "github.com/lightningnetwork/lnd/macaroons"
@@ -82,6 +84,7 @@ type Daemon struct {
8284 internalErrChan chan error
8385
8486 lnd * lndclient.GrpcLndServices
87+ assetClient * assets.TapdClient
8588 clientCleanup func ()
8689
8790 wg sync.WaitGroup
@@ -138,6 +141,14 @@ func (d *Daemon) Start() error {
138141 return err
139142 }
140143
144+ // Initialize the assets client.
145+ if d .cfg .Tapd .Activate {
146+ d .assetClient , err = assets .NewTapdClient (d .cfg .Tapd )
147+ if err != nil {
148+ return err
149+ }
150+ }
151+
141152 // With lnd connected, initialize everything else, such as the swap
142153 // server client, the swap client RPC server instance and our main swap
143154 // and error handlers. If this fails, then nothing has been started yet,
@@ -435,9 +446,26 @@ func (d *Daemon) initialize(withMacaroonService bool) error {
435446 chainParams ,
436447 )
437448
449+ // If we're running an asset client, we'll log something here.
450+ if d .assetClient != nil {
451+ getInfo , err := d .assetClient .GetInfo (
452+ d .mainCtx , & taprpc.GetInfoRequest {},
453+ )
454+ if err != nil {
455+ return fmt .Errorf ("unable to get asset client info: %v" , err )
456+ }
457+ if getInfo .LndIdentityPubkey != d .lnd .NodePubkey .String () {
458+ return fmt .Errorf ("asset client pubkey %v does not match " +
459+ "lnd pubkey %v" , getInfo .LndIdentityPubkey ,
460+ d .lnd .NodePubkey )
461+ }
462+
463+ log .Infof ("Using asset client with version %v" , getInfo .Version )
464+ }
465+
438466 // Create an instance of the loop client library.
439467 swapClient , clientCleanup , err := getClient (
440- d .cfg , swapDb , sweeperDb , & d .lnd .LndServices ,
468+ d .cfg , swapDb , sweeperDb , & d .lnd .LndServices , d . assetClient ,
441469 )
442470 if err != nil {
443471 return err
@@ -667,6 +695,7 @@ func (d *Daemon) initialize(withMacaroonService bool) error {
667695 depositManager : depositManager ,
668696 withdrawalManager : withdrawalManager ,
669697 staticLoopInManager : staticLoopInManager ,
698+ assetClient : d .assetClient ,
670699 }
671700
672701 // Retrieve all currently existing swaps from the database.
0 commit comments