Merge pull request #9470 from ziggie1984/fix-sweepInput-bug
CI / Sqlc check (push) Has been cancelled
CI / RPC and mobile compilation check (push) Has been cancelled
CI / check commits (push) Has been cancelled
CI / lint code (push) Has been cancelled
CI / cross compilation (amd64, darwin-amd64 freebsd-amd64 linux-amd64 netbsd-amd64 openbsd-amd64 windows-amd64) (push) Has been cancelled
CI / cross compilation (arm, darwin-arm64 freebsd-arm linux-armv6 linux-armv7 linux-arm64 windows-arm) (push) Has been cancelled
CI / cross compilation (i386, freebsd-386 linux-386 windows-386) (push) Has been cancelled
CI / sample configuration check (push) Has been cancelled
CI / run unit tests (btcd unit-cover) (push) Has been cancelled
CI / run unit tests (btcd unit-race) (push) Has been cancelled
CI / run unit tests (unit tags="kvdb_etcd") (push) Has been cancelled
CI / run unit tests (unit tags="kvdb_postgres") (push) Has been cancelled
CI / run unit tests (unit tags="kvdb_sqlite") (push) Has been cancelled
CI / run unit tests (unit-module) (push) Has been cancelled
CI / basic itests (backend="bitcoind notxindex", bitcoind-notxindex) (push) Has been cancelled
CI / basic itests (backend=bitcoind cover=1, bitcoind) (push) Has been cancelled
CI / basic itests (backend=btcd cover=1, btcd) (push) Has been cancelled
CI / basic itests (backend=neutrino cover=1, neutrino) (push) Has been cancelled
CI / itests (backend="bitcoind rpcpolling", bitcoind-rpcpolling) (push) Has been cancelled
CI / itests (backend=bitcoind dbbackend=etcd, bitcoind-etcd) (push) Has been cancelled
CI / itests (backend=bitcoind dbbackend=postgres nativesql=true, bitcoind-postgres-nativesql) (push) Has been cancelled
CI / itests (backend=bitcoind dbbackend=postgres, bitcoind-postgres) (push) Has been cancelled
CI / itests (backend=bitcoind dbbackend=sqlite nativesql=true, bitcoind-sqlite-nativesql) (push) Has been cancelled
CI / itests (backend=bitcoind dbbackend=sqlite, bitcoind-sqlite) (push) Has been cancelled
CI / windows itest (push) Has been cancelled
CI / macOS itest (push) Has been cancelled
CI / check pinned dependencies (github.com/golang/protobuf v1.5.3) (push) Has been cancelled
CI / check pinned dependencies (google.golang.org/grpc v1.59.0) (push) Has been cancelled
CI / check release notes updated (push) Has been cancelled
CI / finish (push) Has been cancelled
Docker image build / main (push) Has been cancelled

Make BumpFee RPC user inputs more stricter.
This commit is contained in:
Olaoluwa Osuntokun authored and GitHub committed 2025-02-07 14:39:31 -08:00
commit ce8cde6911
8 files changed
+632 -465

No files matched your search

+5 -5
View File
@@ -490,12 +490,12 @@ func testAnchorThirdPartySpend(ht *lntest.HarnessTest) {
commit.DeadlineHeight, anchor.DeadlineHeight)
// Update the anchor sweep's deadline and budget so it will always be
// swpet.
// swept.
bumpFeeReq := &walletrpc.BumpFeeRequest{
Outpoint: anchor.Outpoint,
TargetConf: uint32(deadline + 100),
Budget: uint64(anchor.AmountSat * 10),
Immediate: true,
Outpoint: anchor.Outpoint,
DeadlineDelta: uint32(deadline + 100),
Budget: uint64(anchor.AmountSat * 10),
Immediate: true,
}
alice.RPC.BumpFee(bumpFeeReq)
+65 -28
View File
@@ -1723,11 +1723,42 @@ func runBumpFee(ht *lntest.HarnessTest, alice *node.HarnessNode) {
// min relay fee rate is used as the current fee rate.
assertFeeRateEqual(startFeeRate)
// First we test the case where we specify the conf target to increase
// the starting fee rate of the fee function.
confTargetFeeRate := chainfee.SatPerVByte(50)
ht.SetFeeEstimateWithConf(confTargetFeeRate.FeePerKWeight(), 3)
// Second bump request - we will specify the conf target and expect a
// starting fee rate that is estimated using the provided estimator.
// - starting fee rate: 50 sat/vbyte (conf target 3).
// - deadline: 1008 (default deadline).
// - budget: 50% of the input value.
bumpFeeReq = &walletrpc.BumpFeeRequest{
Outpoint: op,
// We use a force param to create the sweeping tx immediately.
Immediate: true,
TargetConf: 3,
}
alice.RPC.BumpFee(bumpFeeReq)
// Alice's old sweeping tx should be replaced.
ht.AssertTxNotInMempool(sweepTx1.TxHash())
// Assert the pending sweep is created with the expected values:
// - broadcast attempts: 2.
// - starting fee rate: 50 sat/vbyte (conf target 3).
// - deadline: 1008 (default deadline).
// - budget: 50% of the input value.
sweepTx2 := assertPendingSweepResp(
2, uint64(value/2), deadline, uint64(confTargetFeeRate),
)
// testFeeRate sepcifies a starting fee rate in sat/vbyte.
const testFeeRate = uint64(100)
// Second bump request - we will specify the fee rate and expect a fee
// func that has,
// Third bump request - we will specify the fee rate and expect a fee
// func to change the starting fee rate of the fee function,
// - starting fee rate: 100 sat/vbyte.
// - deadline: 1008 (default deadline).
// - budget: 50% of the input value.
@@ -1740,15 +1771,15 @@ func runBumpFee(ht *lntest.HarnessTest, alice *node.HarnessNode) {
alice.RPC.BumpFee(bumpFeeReq)
// Alice's old sweeping tx should be replaced.
ht.AssertTxNotInMempool(sweepTx1.TxHash())
ht.AssertTxNotInMempool(sweepTx2.TxHash())
// Assert the pending sweep is created with the expected values:
// - broadcast attempts: 2.
// - broadcast attempts: 3.
// - starting fee rate: 100 sat/vbyte.
// - deadline: 1008 (default deadline).
// - budget: 50% of the input value.
sweepTx2 := assertPendingSweepResp(
2, uint64(value/2), deadline, testFeeRate,
sweepTx3 := assertPendingSweepResp(
3, uint64(value/2), deadline, testFeeRate,
)
// We expect the requested starting fee rate to be the current fee
@@ -1758,7 +1789,7 @@ func runBumpFee(ht *lntest.HarnessTest, alice *node.HarnessNode) {
// testBudget specifies a budget in sats.
testBudget := uint64(float64(value) * 0.1)
// Third bump request - we will specify the budget and expect a fee
// Fourth bump request - we will specify the budget and expect a fee
// func that has,
// - starting fee rate: 100 sat/vbyte, stays unchanged.
// - deadline: 1008 (default deadline).
@@ -1772,14 +1803,14 @@ func runBumpFee(ht *lntest.HarnessTest, alice *node.HarnessNode) {
alice.RPC.BumpFee(bumpFeeReq)
// Alice's old sweeping tx should be replaced.
ht.AssertTxNotInMempool(sweepTx2.TxHash())
ht.AssertTxNotInMempool(sweepTx3.TxHash())
// Assert the pending sweep is created with the expected values:
// - broadcast attempts: 3.
// - broadcast attempts: 4.
// - starting fee rate: 100 sat/vbyte, stays unchanged.
// - deadline: 1008 (default deadline).
// - budget: 10% of the input value.
sweepTx3 := assertPendingSweepResp(3, testBudget, deadline, 0)
sweepTx4 := assertPendingSweepResp(4, testBudget, deadline, testFeeRate)
// We expect the current fee rate to be increased because we ensure the
// initial broadcast always succeeds.
@@ -1789,7 +1820,7 @@ func runBumpFee(ht *lntest.HarnessTest, alice *node.HarnessNode) {
testDeadlineDelta := uint32(100)
deadlineHeight := uint32(currentHeight) + testDeadlineDelta
// Fourth bump request - we will specify the deadline and expect a fee
// Fifth bump request - we will specify the deadline and expect a fee
// func that has,
// - starting fee rate: 100 sat/vbyte, stays unchanged.
// - deadline: 100.
@@ -1797,26 +1828,29 @@ func runBumpFee(ht *lntest.HarnessTest, alice *node.HarnessNode) {
bumpFeeReq = &walletrpc.BumpFeeRequest{
Outpoint: op,
// We use a force param to create the sweeping tx immediately.
Immediate: true,
TargetConf: testDeadlineDelta,
Immediate: true,
DeadlineDelta: testDeadlineDelta,
Budget: testBudget,
}
alice.RPC.BumpFee(bumpFeeReq)
// Alice's old sweeping tx should be replaced.
ht.AssertTxNotInMempool(sweepTx3.TxHash())
ht.AssertTxNotInMempool(sweepTx4.TxHash())
// Assert the pending sweep is created with the expected values:
// - broadcast attempts: 4.
// - broadcast attempts: 5.
// - starting fee rate: 100 sat/vbyte, stays unchanged.
// - deadline: 100.
// - budget: 10% of the input value, stays unchanged.
sweepTx4 := assertPendingSweepResp(4, testBudget, deadlineHeight, 0)
sweepTx5 := assertPendingSweepResp(
5, testBudget, deadlineHeight, testFeeRate,
)
// We expect the current fee rate to be increased because we ensure the
// initial broadcast always succeeds.
assertFeeRateGreater(testFeeRate)
// Fifth bump request - we test the behavior of `Immediate` - every
// Sixth bump request - we test the behavior of `Immediate` - every
// time it's called, the fee function will keep increasing the fee rate
// until the broadcast can succeed. The fee func that has,
// - starting fee rate: 100 sat/vbyte, stays unchanged.
@@ -1830,14 +1864,16 @@ func runBumpFee(ht *lntest.HarnessTest, alice *node.HarnessNode) {
alice.RPC.BumpFee(bumpFeeReq)
// Alice's old sweeping tx should be replaced.
ht.AssertTxNotInMempool(sweepTx4.TxHash())
ht.AssertTxNotInMempool(sweepTx5.TxHash())
// Assert the pending sweep is created with the expected values:
// - broadcast attempts: 5.
// - broadcast attempts: 6.
// - starting fee rate: 100 sat/vbyte, stays unchanged.
// - deadline: 100, stays unchanged.
// - budget: 10% of the input value, stays unchanged.
sweepTx5 := assertPendingSweepResp(5, testBudget, deadlineHeight, 0)
sweepTx6 := assertPendingSweepResp(
6, testBudget, deadlineHeight, testFeeRate,
)
// We expect the current fee rate to be increased because we ensure the
// initial broadcast always succeeds.
@@ -1855,26 +1891,27 @@ func runBumpFee(ht *lntest.HarnessTest, alice *node.HarnessNode) {
// We use a force param to create the sweeping tx immediately.
Immediate: true,
SatPerVbyte: startFeeRate,
Budget: smallBudget,
TargetConf: uint32(sweep.DefaultDeadlineDelta),
// The budget and the deadline delta must be set together.
Budget: smallBudget,
DeadlineDelta: uint32(sweep.DefaultDeadlineDelta),
}
alice.RPC.BumpFee(bumpFeeReq)
// Assert the pending sweep is created with the expected values:
// - broadcast attempts: 6.
// - broadcast attempts: 7.
// - starting fee rate: 1 sat/vbyte.
// - deadline: 1008.
// - budget: 1000 sats.
sweepTx6 := assertPendingSweepResp(
6, smallBudget, deadline, startFeeRate,
sweepTx7 := assertPendingSweepResp(
7, smallBudget, deadline, startFeeRate,
)
// Since this budget is too small to cover the RBF, we expect the
// sweeping attempt to fail.
//
require.Equal(ht, sweepTx5.TxHash(), sweepTx6.TxHash(), "tx5 should "+
"not be replaced: tx5=%v, tx6=%v", sweepTx5.TxHash(),
sweepTx6.TxHash())
require.Equal(ht, sweepTx6.TxHash(), sweepTx7.TxHash(), "tx6 should "+
"not be replaced: tx6=%v, tx7=%v", sweepTx6.TxHash(),
sweepTx7.TxHash())
// We expect the current fee rate to be increased because we ensure the
// initial broadcast always succeeds.