mirror of
https://github.com/lightninglabs/loop.git
synced 2026-08-20 13:27:50 +02:00
multi: migrate to btcd v2 modules
Update LND, Aperture, and Taproot Assets to revisions using the btcd v2 modules, and update lndclient to v0.21.0-3. Migrate Loop chain, transaction, and address types to their corresponding v2 packages. The lndclient release includes the migration from: https://github.com/lightninglabs/lndclient/pull/280 Taproot Assets is temporarily replaced with its btcd v2 revision because the v0.8 release branch has not adopted the new modules. This raises the minimum Go version to 1.26 and changes exported address types.
This commit is contained in:
parent
6d1dbcb599
commit
d554b42ef6
172 changed files with 693 additions and 978 deletions
|
|
@ -9,7 +9,7 @@ import (
|
|||
"path/filepath"
|
||||
"time"
|
||||
|
||||
"github.com/btcsuite/btcd/btcutil"
|
||||
"github.com/btcsuite/btcd/btcutil/v2"
|
||||
"github.com/lightninglabs/aperture/l402"
|
||||
"github.com/lightninglabs/loop/assets"
|
||||
"github.com/lightninglabs/loop/loopdb"
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import (
|
|||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"github.com/btcsuite/btcd/btcutil"
|
||||
"github.com/btcsuite/btcd/btcutil/v2"
|
||||
"github.com/lightninglabs/loop/assets"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@ import (
|
|||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/btcsuite/btcd/chaincfg"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/btcsuite/btcd/chaincfg/v2"
|
||||
"github.com/btcsuite/btcd/wire/v2"
|
||||
"github.com/lightninglabs/loop/looprpc"
|
||||
"github.com/lightninglabs/loop/swapserverrpc"
|
||||
)
|
||||
|
|
|
|||
|
|
@ -6,9 +6,10 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/btcsuite/btcd/btcutil"
|
||||
"github.com/btcsuite/btcd/txscript"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
btcaddr "github.com/btcsuite/btcd/address/v2"
|
||||
"github.com/btcsuite/btcd/btcutil/v2"
|
||||
"github.com/btcsuite/btcd/txscript/v2"
|
||||
"github.com/btcsuite/btcd/wire/v2"
|
||||
"github.com/lightninglabs/loop/loopdb"
|
||||
"github.com/lightninglabs/loop/swap"
|
||||
"github.com/lightninglabs/loop/swapserverrpc"
|
||||
|
|
@ -100,7 +101,7 @@ func newHtlcConfirmedRecoveryFixture(
|
|||
},
|
||||
}
|
||||
|
||||
destAddr, err := btcutil.NewAddressWitnessPubKeyHash(
|
||||
destAddr, err := btcaddr.NewAddressWitnessPubKeyHash(
|
||||
bytes.Repeat([]byte{2}, 20), lnd.ChainParams,
|
||||
)
|
||||
require.NoError(t, err)
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import (
|
|||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/btcsuite/btcd/chaincfg"
|
||||
"github.com/btcsuite/btcd/chaincfg/v2"
|
||||
"github.com/lightninglabs/loop"
|
||||
"github.com/lightninglabs/loop/staticaddr/loopin"
|
||||
)
|
||||
|
|
|
|||
|
|
@ -14,10 +14,11 @@ import (
|
|||
"sync"
|
||||
"time"
|
||||
|
||||
btcaddr "github.com/btcsuite/btcd/address/v2"
|
||||
"github.com/btcsuite/btcd/btcec/v2"
|
||||
"github.com/btcsuite/btcd/btcutil"
|
||||
"github.com/btcsuite/btcd/chaincfg"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/btcsuite/btcd/btcutil/v2"
|
||||
"github.com/btcsuite/btcd/chaincfg/v2"
|
||||
"github.com/btcsuite/btcd/wire/v2"
|
||||
"github.com/lightninglabs/aperture/l402"
|
||||
"github.com/lightninglabs/lndclient"
|
||||
"github.com/lightninglabs/loop"
|
||||
|
|
@ -158,7 +159,7 @@ func (s *swapClientServer) LoopOut(ctx context.Context,
|
|||
s.config.TotalPaymentTimeout)
|
||||
}
|
||||
|
||||
var sweepAddr btcutil.Address
|
||||
var sweepAddr btcaddr.Address
|
||||
var isExternalAddr bool
|
||||
var err error
|
||||
//nolint:lll
|
||||
|
|
@ -170,7 +171,7 @@ func (s *swapClientServer) LoopOut(ctx context.Context,
|
|||
case in.Dest != "":
|
||||
// Decode the client provided destination address for the loop
|
||||
// out sweep.
|
||||
sweepAddr, err = btcutil.DecodeAddress(
|
||||
sweepAddr, err = btcaddr.DecodeAddress(
|
||||
in.Dest, s.lnd.ChainParams,
|
||||
)
|
||||
if err != nil {
|
||||
|
|
@ -2374,7 +2375,7 @@ func staticAddressLoopInSwapInfoWithChainParams(
|
|||
// staticAddressLoopInHtlcAddress reconstructs the V2 P2WSH HTLC address from
|
||||
// the static-address loop-in's client and server keys.
|
||||
func staticAddressLoopInHtlcAddress(swp *loopin.StaticAddressLoopIn,
|
||||
chainParams *chaincfg.Params) (btcutil.Address, error) {
|
||||
chainParams *chaincfg.Params) (btcaddr.Address, error) {
|
||||
|
||||
if swp.ClientPubkey == nil {
|
||||
return nil, errors.New("missing static address loop-in client HTLC key")
|
||||
|
|
@ -2954,7 +2955,7 @@ func validateLoopInRequest(htlcConfTarget int32, external bool,
|
|||
// loop amount is valid given the available balance.
|
||||
func validateLoopOutRequest(ctx context.Context, lnd lndclient.LightningClient,
|
||||
chainParams *chaincfg.Params, req *looprpc.LoopOutRequest,
|
||||
sweepAddr btcutil.Address, maxParts uint32) (int32, error) {
|
||||
sweepAddr btcaddr.Address, maxParts uint32) (int32, error) {
|
||||
|
||||
// Check that the provided destination address has the correct format
|
||||
// for the active network.
|
||||
|
|
@ -2966,11 +2967,11 @@ func validateLoopOutRequest(ctx context.Context, lnd lndclient.LightningClient,
|
|||
// Check that the provided destination address is a supported
|
||||
// address format.
|
||||
switch sweepAddr.(type) {
|
||||
case *btcutil.AddressTaproot,
|
||||
*btcutil.AddressWitnessScriptHash,
|
||||
*btcutil.AddressWitnessPubKeyHash,
|
||||
*btcutil.AddressScriptHash,
|
||||
*btcutil.AddressPubKeyHash:
|
||||
case *btcaddr.AddressTaproot,
|
||||
*btcaddr.AddressWitnessScriptHash,
|
||||
*btcaddr.AddressWitnessPubKeyHash,
|
||||
*btcaddr.AddressScriptHash,
|
||||
*btcaddr.AddressPubKeyHash:
|
||||
|
||||
default:
|
||||
return 0, errInvalidAddress
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ package loopd
|
|||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/btcsuite/btcd/chainhash/v2"
|
||||
"github.com/btcsuite/btcd/wire/v2"
|
||||
"github.com/lightninglabs/loop/staticaddr/deposit"
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -4,10 +4,11 @@ import (
|
|||
"context"
|
||||
"testing"
|
||||
|
||||
btcaddr "github.com/btcsuite/btcd/address/v2"
|
||||
"github.com/btcsuite/btcd/btcec/v2"
|
||||
"github.com/btcsuite/btcd/btcutil"
|
||||
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/btcsuite/btcd/btcutil/v2"
|
||||
"github.com/btcsuite/btcd/chainhash/v2"
|
||||
"github.com/btcsuite/btcd/wire/v2"
|
||||
"github.com/btcsuite/btclog/v2"
|
||||
"github.com/lightninglabs/loop/looprpc"
|
||||
"github.com/lightninglabs/loop/staticaddr/address"
|
||||
|
|
@ -83,7 +84,7 @@ func (s *staticAddrTestAddressManager) ListUnspent(context.Context,
|
|||
}
|
||||
|
||||
func (s *staticAddrTestAddressManager) GetTaprootAddress(
|
||||
*btcec.PublicKey, *btcec.PublicKey, int64) (*btcutil.AddressTaproot,
|
||||
*btcec.PublicKey, *btcec.PublicKey, int64) (*btcaddr.AddressTaproot,
|
||||
error) {
|
||||
|
||||
return nil, nil
|
||||
|
|
|
|||
|
|
@ -7,11 +7,12 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
btcaddr "github.com/btcsuite/btcd/address/v2"
|
||||
"github.com/btcsuite/btcd/btcec/v2/schnorr"
|
||||
"github.com/btcsuite/btcd/btcutil"
|
||||
"github.com/btcsuite/btcd/chaincfg"
|
||||
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/btcsuite/btcd/btcutil/v2"
|
||||
"github.com/btcsuite/btcd/chaincfg/v2"
|
||||
"github.com/btcsuite/btcd/chainhash/v2"
|
||||
"github.com/btcsuite/btcd/wire/v2"
|
||||
"github.com/btcsuite/btclog/v2"
|
||||
"github.com/lightninglabs/lndclient"
|
||||
"github.com/lightninglabs/loop"
|
||||
|
|
@ -39,15 +40,15 @@ import (
|
|||
)
|
||||
|
||||
var (
|
||||
testnetAddr, _ = btcutil.NewAddressScriptHash(
|
||||
testnetAddr, _ = btcaddr.NewAddressScriptHash(
|
||||
[]byte{123}, &chaincfg.TestNet3Params,
|
||||
)
|
||||
|
||||
mainnetAddr, _ = btcutil.NewAddressScriptHash(
|
||||
mainnetAddr, _ = btcaddr.NewAddressScriptHash(
|
||||
[]byte{123}, &chaincfg.MainNetParams,
|
||||
)
|
||||
|
||||
nodepubkeyAddr, _ = btcutil.DecodeAddress(
|
||||
nodepubkeyAddr, _ = btcaddr.DecodeAddress(
|
||||
mock_lnd.NewMockLnd().NodePubkey, &chaincfg.MainNetParams,
|
||||
)
|
||||
|
||||
|
|
@ -876,7 +877,7 @@ func newGenericStaticLoopInServer(t *testing.T) (*swapClientServer,
|
|||
}
|
||||
|
||||
func newTestStaticAddressParams(t *testing.T) (*script.Parameters,
|
||||
*btcutil.AddressTaproot) {
|
||||
*btcaddr.AddressTaproot) {
|
||||
|
||||
t.Helper()
|
||||
|
||||
|
|
@ -893,7 +894,7 @@ func newTestStaticAddressParams(t *testing.T) (*script.Parameters,
|
|||
staticPkScript, err := staticAddress.StaticAddressScript()
|
||||
require.NoError(t, err)
|
||||
|
||||
taprootAddress, err := btcutil.NewAddressTaproot(
|
||||
taprootAddress, err := btcaddr.NewAddressTaproot(
|
||||
schnorr.SerializePubKey(staticAddress.TaprootKey),
|
||||
&chaincfg.TestNet3Params,
|
||||
)
|
||||
|
|
@ -1176,7 +1177,7 @@ func TestValidateLoopOutRequest(t *testing.T) {
|
|||
name string
|
||||
chain chaincfg.Params
|
||||
confTarget int32
|
||||
destAddr btcutil.Address
|
||||
destAddr btcaddr.Address
|
||||
label string
|
||||
channels []lndclient.ChannelInfo
|
||||
outgoingChanSet []uint64
|
||||
|
|
|
|||
|
|
@ -4,11 +4,12 @@ import (
|
|||
"bytes"
|
||||
"context"
|
||||
|
||||
"github.com/btcsuite/btcd/btcutil"
|
||||
"github.com/btcsuite/btcd/chaincfg"
|
||||
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||
"github.com/btcsuite/btcd/txscript"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
btcaddr "github.com/btcsuite/btcd/address/v2"
|
||||
"github.com/btcsuite/btcd/btcutil/v2"
|
||||
"github.com/btcsuite/btcd/chaincfg/v2"
|
||||
"github.com/btcsuite/btcd/chainhash/v2"
|
||||
"github.com/btcsuite/btcd/txscript/v2"
|
||||
"github.com/btcsuite/btcd/wire/v2"
|
||||
"github.com/lightninglabs/lndclient"
|
||||
"github.com/lightninglabs/loop/labels"
|
||||
"github.com/lightninglabs/loop/loopdb"
|
||||
|
|
@ -48,7 +49,7 @@ type htlcWallet interface {
|
|||
// NextAddr derives the next address from the given account and type.
|
||||
NextAddr(ctx context.Context, account string,
|
||||
addrType walletrpc.AddressType,
|
||||
change bool) (btcutil.Address, error)
|
||||
change bool) (btcaddr.Address, error)
|
||||
|
||||
// PublishTransaction broadcasts the transaction with the given label.
|
||||
PublishTransaction(ctx context.Context, tx *wire.MsgTx,
|
||||
|
|
@ -87,7 +88,7 @@ func sweepHtlc(ctx context.Context, req *looprpc.SweepHtlcRequest,
|
|||
}
|
||||
|
||||
// Parse the inputs.
|
||||
htlcAddr, err := btcutil.DecodeAddress(
|
||||
htlcAddr, err := btcaddr.DecodeAddress(
|
||||
req.HtlcAddress, chainParams,
|
||||
)
|
||||
if err != nil {
|
||||
|
|
@ -108,9 +109,9 @@ func sweepHtlc(ctx context.Context, req *looprpc.SweepHtlcRequest,
|
|||
|
||||
// Destination address: honor a provided override immediately so request
|
||||
// validation stays independent from swap lookup.
|
||||
var sweepAddr btcutil.Address
|
||||
var sweepAddr btcaddr.Address
|
||||
if req.DestAddress != "" {
|
||||
sweepAddr, err = btcutil.DecodeAddress(
|
||||
sweepAddr, err = btcaddr.DecodeAddress(
|
||||
req.DestAddress, chainParams,
|
||||
)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -7,9 +7,10 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/btcsuite/btcd/btcutil"
|
||||
"github.com/btcsuite/btcd/txscript"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
btcaddr "github.com/btcsuite/btcd/address/v2"
|
||||
"github.com/btcsuite/btcd/btcutil/v2"
|
||||
"github.com/btcsuite/btcd/txscript/v2"
|
||||
"github.com/btcsuite/btcd/wire/v2"
|
||||
"github.com/btcsuite/btclog/v2"
|
||||
"github.com/lightninglabs/loop/loopdb"
|
||||
"github.com/lightninglabs/loop/looprpc"
|
||||
|
|
@ -346,7 +347,7 @@ func TestSweepHtlc(t *testing.T) {
|
|||
ProtocolVersion: loopdb.ProtocolVersionHtlcV2,
|
||||
}
|
||||
|
||||
destAddr, err := btcutil.NewAddressWitnessPubKeyHash(
|
||||
destAddr, err := btcaddr.NewAddressWitnessPubKeyHash(
|
||||
bytes.Repeat([]byte{1}, 20), lnd.ChainParams,
|
||||
)
|
||||
require.NoError(t, err)
|
||||
|
|
@ -514,7 +515,7 @@ func TestSweepHtlc(t *testing.T) {
|
|||
// record does not define one.
|
||||
expectedAddr := loopOut.Contract.DestAddr
|
||||
if req.DestAddress != "" {
|
||||
expectedAddr, err = btcutil.DecodeAddress(
|
||||
expectedAddr, err = btcaddr.DecodeAddress(
|
||||
req.DestAddress, lnd.ChainParams,
|
||||
)
|
||||
require.NoError(t, err)
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@ import (
|
|||
"fmt"
|
||||
"slices"
|
||||
|
||||
"github.com/btcsuite/btcd/btcutil"
|
||||
"github.com/btcsuite/btcd/chaincfg"
|
||||
"github.com/btcsuite/btcd/btcutil/v2"
|
||||
"github.com/btcsuite/btcd/chaincfg/v2"
|
||||
"github.com/lightninglabs/aperture/l402"
|
||||
"github.com/lightninglabs/lndclient"
|
||||
"github.com/lightninglabs/loop"
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import (
|
|||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/btcsuite/btcd/chaincfg"
|
||||
"github.com/btcsuite/btcd/chaincfg/v2"
|
||||
"github.com/lightninglabs/lndclient"
|
||||
"github.com/lightninglabs/loop"
|
||||
"github.com/lightninglabs/loop/assets"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue