From 8c77829c46d7b6792a43b408d3d4e54005010642 Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Wed, 5 Jan 2022 11:04:16 +0100 Subject: [PATCH] lnwallet+lntest+mod: bump btcwallet to export ScriptForOutput --- go.mod | 2 +- go.sum | 4 ++-- lntest/mock/walletcontroller.go | 9 +++++++++ lnwallet/btcwallet/signer.go | 9 +++++++++ lnwallet/interface.go | 6 ++++++ 5 files changed, 27 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 0af0bdadf..e39c81af5 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f github.com/btcsuite/btcutil v1.0.3-0.20210527170813-e2ba6805a890 github.com/btcsuite/btcutil/psbt v1.0.3-0.20210527170813-e2ba6805a890 - github.com/btcsuite/btcwallet v0.13.0 + github.com/btcsuite/btcwallet v0.13.1-0.20211201210108-79de92f527dc github.com/btcsuite/btcwallet/wallet/txauthor v1.1.0 github.com/btcsuite/btcwallet/wallet/txrules v1.1.0 github.com/btcsuite/btcwallet/walletdb v1.3.6-0.20210803004036-eebed51155ec diff --git a/go.sum b/go.sum index 413d72a42..ecdf732c6 100644 --- a/go.sum +++ b/go.sum @@ -97,8 +97,8 @@ github.com/btcsuite/btcutil v1.0.3-0.20210527170813-e2ba6805a890/go.mod h1:0DVlH github.com/btcsuite/btcutil/psbt v1.0.3-0.20201208143702-a53e38424cce/go.mod h1:LVveMu4VaNSkIRTZu2+ut0HDBRuYjqGocxDMNS1KuGQ= github.com/btcsuite/btcutil/psbt v1.0.3-0.20210527170813-e2ba6805a890 h1:0xUNvvwJ7RjzBs4nCF+YrK28S5P/b4uHkpPxY1ovGY4= github.com/btcsuite/btcutil/psbt v1.0.3-0.20210527170813-e2ba6805a890/go.mod h1:LVveMu4VaNSkIRTZu2+ut0HDBRuYjqGocxDMNS1KuGQ= -github.com/btcsuite/btcwallet v0.13.0 h1:gtLWwueRm27KQiHJpycybv3uMdK1eo87JexfTfzvEhk= -github.com/btcsuite/btcwallet v0.13.0/go.mod h1:iLN1lG1MW0eREm+SikmPO8AZPz5NglBTEK/ErqkjGpo= +github.com/btcsuite/btcwallet v0.13.1-0.20211201210108-79de92f527dc h1:lAbAEAp4eWvsSwJfcpdHXpKz78X2sVF9aDK4nJveXmY= +github.com/btcsuite/btcwallet v0.13.1-0.20211201210108-79de92f527dc/go.mod h1:iLN1lG1MW0eREm+SikmPO8AZPz5NglBTEK/ErqkjGpo= github.com/btcsuite/btcwallet/wallet/txauthor v1.0.0/go.mod h1:VufDts7bd/zs3GV13f/lXc/0lXrPnvxD/NvmpG/FEKU= github.com/btcsuite/btcwallet/wallet/txauthor v1.1.0 h1:8pO0pvPX1rFRfRiol4oV6kX7dY5y4chPwhfVwUfvwtk= github.com/btcsuite/btcwallet/wallet/txauthor v1.1.0/go.mod h1:ktYuJyumYtwG+QQ832Q+kqvxWJRAei3Nqs5qhSn4nww= diff --git a/lntest/mock/walletcontroller.go b/lntest/mock/walletcontroller.go index 7df080257..72da14b14 100644 --- a/lntest/mock/walletcontroller.go +++ b/lntest/mock/walletcontroller.go @@ -53,6 +53,15 @@ func (w *WalletController) FetchInputInfo( return utxo, nil } +// ScriptForOutput returns the address, witness program and redeem script for a +// given UTXO. An error is returned if the UTXO does not belong to our wallet or +// it is not a managed pubKey address. +func (w *WalletController) ScriptForOutput(*wire.TxOut) ( + waddrmgr.ManagedPubKeyAddress, []byte, []byte, error) { + + return nil, nil, nil, nil +} + // ConfirmedBalance currently returns dummy values. func (w *WalletController) ConfirmedBalance(int32, string) (btcutil.Amount, error) { diff --git a/lnwallet/btcwallet/signer.go b/lnwallet/btcwallet/signer.go index a6a525e7d..cea9b977c 100644 --- a/lnwallet/btcwallet/signer.go +++ b/lnwallet/btcwallet/signer.go @@ -44,6 +44,15 @@ func (b *BtcWallet) FetchInputInfo(prevOut *wire.OutPoint) (*lnwallet.Utxo, erro }, nil } +// ScriptForOutput returns the address, witness program and redeem script for a +// given UTXO. An error is returned if the UTXO does not belong to our wallet or +// it is not a managed pubKey address. +func (b *BtcWallet) ScriptForOutput(output *wire.TxOut) ( + waddrmgr.ManagedPubKeyAddress, []byte, []byte, error) { + + return b.wallet.ScriptForOutput(output) +} + // deriveFromKeyLoc attempts to derive a private key using a fully specified // KeyLocator. func deriveFromKeyLoc(scopedMgr *waddrmgr.ScopedKeyManager, diff --git a/lnwallet/interface.go b/lnwallet/interface.go index c6531ebd9..a8e14dfff 100644 --- a/lnwallet/interface.go +++ b/lnwallet/interface.go @@ -158,6 +158,12 @@ type WalletController interface { // a non-nil error value of ErrNotMine should be returned instead. FetchInputInfo(prevOut *wire.OutPoint) (*Utxo, error) + // ScriptForOutput returns the address, witness program and redeem + // script for a given UTXO. An error is returned if the UTXO does not + // belong to our wallet or it is not a managed pubKey address. + ScriptForOutput(output *wire.TxOut) (waddrmgr.ManagedPubKeyAddress, + []byte, []byte, error) + // ConfirmedBalance returns the sum of all the wallet's unspent outputs // that have at least confs confirmations. If confs is set to zero, // then all unspent outputs, including those currently in the mempool