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

[wallet]: only select BIP-86 script keys for channel funding, add flag to FundVirtualPsbt #1115

Merged
merged 4 commits into from
Sep 10, 2024

Conversation

guggero
Copy link
Member

@guggero guggero commented Sep 3, 2024

Fixes a bug that caused channel funding transactions to be mistakenly used for coin selection, even though they are known to be script path only spend assets.

@guggero guggero requested review from Roasbeef and jharveyb September 3, 2024 18:34
@coveralls
Copy link

coveralls commented Sep 3, 2024

Pull Request Test Coverage Report for Build 10697119132

Details

  • 5 of 33 (15.15%) changed or added relevant lines in 6 files are covered.
  • 16 unchanged lines in 4 files lost coverage.
  • Overall coverage decreased (-0.007%) to 40.175%

Changes Missing Coverage Covered Lines Changed/Added Lines %
tapchannel/aux_funding_controller.go 0 1 0.0%
tapfreighter/chain_porter.go 0 1 0.0%
tapfreighter/wallet.go 0 4 0.0%
rpcserver.go 0 22 0.0%
Files with Coverage Reduction New Missed Lines %
tapchannel/aux_funding_controller.go 1 0.0%
tapgarden/caretaker.go 4 68.87%
commitment/tap.go 4 83.91%
tapdb/multiverse.go 7 60.32%
Totals Coverage Status
Change from base Build 10628247677: -0.007%
Covered Lines: 23981
Relevant Lines: 59692

💛 - Coveralls

@dstadulis dstadulis added this to the v0.4.2 milestone Sep 3, 2024
Copy link
Member

@Roasbeef Roasbeef left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice fix!

@@ -994,7 +994,7 @@ func (p *ChainPorter) stateStep(currentPkg sendPackage) (*sendPackage, error) {
"address parcel")
}
fundSendRes, err := p.cfg.AssetWallet.FundAddressSend(
ctx, addrParcel.destAddrs...,
ctx, true, addrParcel.destAddrs...,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can make this diff/change and future call sites more readable if we introduce an enum early here instead of a bool.

It could be something like (random names, can def be improved):

type CoinSelectType uint8

const (
    DefaultCoinSelect CoinSelectType
    Bip86Only
    ScriptTreesAllowed 
)

Then we can make DefaultCoinSelect = Bip86Only when parsing, which is typically the behavior you want unless doing something fancy.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense! Changed the type. But had to keep the default value at ScriptTreesAllowed to not break existing users of the FundVirtualPsbts RPC call (which is primarily used for doing script sends, at least in our itests).

tapfreighter/wallet.go Outdated Show resolved Hide resolved
itest/mint_fund_seal_test.go Show resolved Hide resolved
@guggero guggero requested a review from Roasbeef September 4, 2024 07:30
Copy link
Contributor

@jharveyb jharveyb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, AFAICT the default for FundVirtualPsbt will be the same but FundAddressSend will be BIP86 only.

Would be nice to have less negations in the path from the enum to the actual DB filter, but minor nit / non-blocking.

itest/mint_fund_seal_test.go Show resolved Hide resolved
@guggero
Copy link
Member Author

guggero commented Sep 5, 2024

have less negations in the path from the enum to the actual DB filter

I'm not sure what you mean. Are you referencing the naming/wording from "only" and "allowed" that is later mapped to a single boolean?

Copy link
Member

@Roasbeef Roasbeef left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 📈

@Roasbeef Roasbeef merged commit 566b409 into lightninglabs:main Sep 10, 2024
18 checks passed
@guggero guggero deleted the fix-bi86-keys-only branch September 10, 2024 07:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

5 participants