chanfunding: adds ability to fund up to some maximum amount

Allows to define a maximum amount to provision a channel
opening with using a new field `FundUpToMaxAmt` on the
`Request` struct. Also adds a new coin select function
`CoinSelectUpToAmount` to select coins up to a maximum
amount respecting a minimum amount.
This commit is contained in:
Bjarne Magnussen authored and Slyghtning committed 2023-04-05 23:05:06 +02:00
1 parent f97454d4ff
commit 0c8aa81ed5
6 files changed
+370 -7

No files matched your search

+9 -1
View File
@@ -514,12 +514,20 @@ func NewPsbtAssembler(fundingAmt btcutil.Amount, basePsbt *psbt.Packet,
//
// NOTE: This method satisfies the chanfunding.Assembler interface.
func (p *PsbtAssembler) ProvisionChannel(req *Request) (Intent, error) {
// We'll exit out if this field is set as the funding transaction will
// We'll exit out if SubtractFees is set as the funding transaction will
// be assembled externally, so we don't influence coin selection.
if req.SubtractFees {
return nil, fmt.Errorf("SubtractFees not supported for PSBT")
}
// We'll exit out if FundUpToMaxAmt or MinFundAmt is set as the funding
// transaction will be assembled externally, so we don't influence coin
// selection.
if req.FundUpToMaxAmt != 0 || req.MinFundAmt != 0 {
return nil, fmt.Errorf("FundUpToMaxAmt and MinFundAmt not " +
"supported for PSBT")
}
intent := &PsbtIntent{
ShimIntent: ShimIntent{
localFundingAmt: p.fundingAmt,