@@ -587,3 +587,47 @@ func runBumpFee(ht *lntest.HarnessTest, alice *node.HarnessNode) {
587
587
// Clean up the mempool.
588
588
ht .MineBlocksAndAssertNumTxes (1 , 2 )
589
589
}
590
+
591
+ // testBumpFeeExternalInput assert that when the bump fee RPC is called with an
592
+ // outpoint unknown to the node's wallet, an error is returned.
593
+ func testBumpFeeExternalInput (ht * lntest.HarnessTest ) {
594
+ alice := ht .NewNode ("Alice" , nil )
595
+ bob := ht .NewNode ("Bob" , nil )
596
+
597
+ // We'll start the test by sending Alice some coins, which she'll use
598
+ // to send to Bob.
599
+ ht .FundCoins (btcutil .SatoshiPerBitcoin , alice )
600
+
601
+ // Alice sends 0.5 BTC to Bob. This tx should have two outputs - one
602
+ // that belongs to Bob, the other is Alice's change output.
603
+ tx := ht .SendCoins (alice , bob , btcutil .SatoshiPerBitcoin / 2 )
604
+ txid := tx .TxHash ()
605
+
606
+ // Find the wrong index to perform the fee bump. We assume the first
607
+ // output belongs to Bob, and switch to the second if the second output
608
+ // has a larger output value. Given we've funded Alice 1 btc, she then
609
+ // sends 0.5 btc to Bob, her change output will be below 0.5 btc after
610
+ // paying the mining fees.
611
+ wrongIndex := 0
612
+ if tx .TxOut [0 ].Value < tx .TxOut [1 ].Value {
613
+ wrongIndex = 1
614
+ }
615
+
616
+ // Alice now tries to bump the wrong output on this tx.
617
+ op := & lnrpc.OutPoint {
618
+ TxidBytes : txid [:],
619
+ OutputIndex : uint32 (wrongIndex ),
620
+ }
621
+
622
+ // Create a request with the wrong outpoint.
623
+ bumpFeeReq := & walletrpc.BumpFeeRequest {
624
+ Outpoint : op ,
625
+ // We use a force param to create the sweeping tx immediately.
626
+ Immediate : true ,
627
+ }
628
+ err := alice .RPC .BumpFeeAssertErr (bumpFeeReq )
629
+ require .ErrorContains (ht , err , "does not belong to the wallet" )
630
+
631
+ // Clean up the mempool.
632
+ ht .MineBlocksAndAssertNumTxes (1 , 1 )
633
+ }
0 commit comments