@@ -1758,97 +1758,99 @@ func testPublishTransaction(r *rpctest.Harness,
1758
1758
tx3 , tx3Spend * wire.MsgTx
1759
1759
)
1760
1760
t .Run ("rbf_tests" , func (t * testing.T ) {
1761
- for _ , rbf := range []bool {false , true } {
1762
- // Now we'll try to double spend an output with a
1763
- // different transaction. Create a new tx and publish
1764
- // it. This is the output we'll try to double spend.
1765
- tx3 = newTx (t , r , keyDesc .PubKey , alice , false )
1766
- err := alice .PublishTransaction (tx3 , labels .External )
1767
- require .NoError (t , err )
1768
-
1769
- // Mine the transaction.
1770
- err = mineAndAssert (r , tx3 )
1771
- require .NoError (t , err )
1761
+ // Starting with bitcoind v28.0 and later, mempool full RBF is
1762
+ // turned on, so there's no way to _not_ signal RBF anymore.
1763
+ const rbf = true
1764
+
1765
+ // Now we'll try to double spend an output with a
1766
+ // different transaction. Create a new tx and publish
1767
+ // it. This is the output we'll try to double spend.
1768
+ tx3 = newTx (t , r , keyDesc .PubKey , alice , false )
1769
+ err := alice .PublishTransaction (tx3 , labels .External )
1770
+ require .NoError (t , err )
1772
1771
1773
- // Now we create a transaction that spends the output
1774
- // from the tx just mined.
1775
- tx4 , err := txFromOutput (
1776
- tx3 , alice .Cfg .Signer , keyDesc .PubKey ,
1777
- keyDesc .PubKey , txFee , rbf ,
1778
- )
1779
- require .NoError (t , err )
1772
+ // Mine the transaction.
1773
+ err = mineAndAssert (r , tx3 )
1774
+ require .NoError (t , err )
1780
1775
1781
- // This should be accepted into the mempool.
1782
- err = alice .PublishTransaction (tx4 , labels .External )
1783
- require .NoError (t , err )
1776
+ // Now we create a transaction that spends the output
1777
+ // from the tx just mined.
1778
+ tx4 , err := txFromOutput (
1779
+ tx3 , alice .Cfg .Signer , keyDesc .PubKey ,
1780
+ keyDesc .PubKey , txFee , rbf ,
1781
+ )
1782
+ require .NoError (t , err )
1784
1783
1785
- // Keep track of the last successfully published tx to
1786
- // spend tx3.
1787
- tx3Spend = tx4
1784
+ // This should be accepted into the mempool.
1785
+ err = alice . PublishTransaction ( tx4 , labels . External )
1786
+ require . NoError ( t , err )
1788
1787
1789
- txid4 := tx4 . TxHash ()
1790
- err = waitForMempoolTx ( r , & txid4 )
1791
- require . NoError ( t , err , "tx not relayed to miner" )
1788
+ // Keep track of the last successfully published tx to
1789
+ // spend tx3.
1790
+ tx3Spend = tx4
1792
1791
1793
- // Create a new key we'll pay to, to ensure we create a
1794
- // unique transaction.
1795
- keyDesc2 , err := alice .DeriveNextKey (
1796
- keychain .KeyFamilyMultiSig ,
1797
- )
1798
- require .NoError (t , err , "unable to obtain public key" )
1792
+ txid4 := tx4 .TxHash ()
1793
+ err = waitForMempoolTx (r , & txid4 )
1794
+ require .NoError (t , err , "tx not relayed to miner" )
1799
1795
1800
- // Create a new transaction that spends the output from
1801
- // tx3, and that pays to a different address.
1802
- tx5 , err := txFromOutput (
1803
- tx3 , alice .Cfg .Signer , keyDesc .PubKey ,
1804
- keyDesc2 .PubKey , txFee , rbf ,
1805
- )
1806
- require .NoError (t , err )
1796
+ // Create a new key we'll pay to, to ensure we create a
1797
+ // unique transaction.
1798
+ keyDesc2 , err := alice .DeriveNextKey (
1799
+ keychain .KeyFamilyMultiSig ,
1800
+ )
1801
+ require .NoError (t , err , "unable to obtain public key" )
1807
1802
1808
- err = alice .PublishTransaction (tx5 , labels .External )
1803
+ // Create a new transaction that spends the output from
1804
+ // tx3, and that pays to a different address.
1805
+ tx5 , err := txFromOutput (
1806
+ tx3 , alice .Cfg .Signer , keyDesc .PubKey ,
1807
+ keyDesc2 .PubKey , txFee , rbf ,
1808
+ )
1809
+ require .NoError (t , err )
1809
1810
1810
- // If RBF is not enabled, we expect this to be rejected
1811
- // because it is a double spend.
1812
- expectedErr := lnwallet .ErrDoubleSpend
1811
+ err = alice .PublishTransaction (tx5 , labels .External )
1813
1812
1814
- // If RBF is enabled, we expect it to be rejected
1815
- // because it doesn't pay enough fees.
1816
- if rbf {
1817
- expectedErr = chain .ErrInsufficientFee
1818
- }
1813
+ // If RBF is not enabled, we expect this to be rejected
1814
+ // because it is a double spend.
1815
+ expectedErr := lnwallet .ErrDoubleSpend
1819
1816
1820
- // Assert the expected error.
1821
- require .ErrorIsf (t , err , expectedErr , "has rbf=%v" , rbf )
1817
+ // If RBF is enabled, we expect it to be rejected
1818
+ // because it doesn't pay enough fees.
1819
+ if rbf {
1820
+ expectedErr = chain .ErrInsufficientFee
1821
+ }
1822
1822
1823
- // Create another transaction that spends the same
1824
- // output, but has a higher fee. We expect also this tx
1825
- // to be rejected for non-RBF enabled transactions,
1826
- // while it should succeed otherwise.
1827
- pubKey3 , err := alice .DeriveNextKey (
1828
- keychain .KeyFamilyMultiSig ,
1829
- )
1830
- require .NoError (t , err , "unable to obtain public key" )
1823
+ // Assert the expected error.
1824
+ require .ErrorIsf (t , err , expectedErr , "has rbf=%v" , rbf )
1831
1825
1832
- tx6 , err := txFromOutput (
1833
- tx3 , alice .Cfg .Signer , keyDesc .PubKey ,
1834
- pubKey3 .PubKey , 2 * txFee , rbf ,
1835
- )
1836
- require .NoError (t , err )
1826
+ // Create another transaction that spends the same
1827
+ // output, but has a higher fee. We expect also this tx
1828
+ // to be rejected for non-RBF enabled transactions,
1829
+ // while it should succeed otherwise.
1830
+ pubKey3 , err := alice .DeriveNextKey (
1831
+ keychain .KeyFamilyMultiSig ,
1832
+ )
1833
+ require .NoError (t , err , "unable to obtain public key" )
1837
1834
1838
- // Expect rejection in non-RBF case.
1839
- expErr := lnwallet .ErrDoubleSpend
1840
- if rbf {
1841
- // Expect success in rbf case.
1842
- expErr = nil
1843
- tx3Spend = tx6
1844
- }
1845
- err = alice .PublishTransaction (tx6 , labels .External )
1846
- require .ErrorIs (t , err , expErr )
1835
+ tx6 , err := txFromOutput (
1836
+ tx3 , alice .Cfg .Signer , keyDesc .PubKey ,
1837
+ pubKey3 .PubKey , 2 * txFee , rbf ,
1838
+ )
1839
+ require .NoError (t , err )
1847
1840
1848
- // Mine the tx spending tx3.
1849
- err = mineAndAssert (r , tx3Spend )
1850
- require .NoError (t , err )
1841
+ // Expect rejection in non-RBF case.
1842
+ expErr := lnwallet .ErrDoubleSpend
1843
+ if rbf {
1844
+ // Expect success in rbf case.
1845
+ expErr = nil
1846
+ tx3Spend = tx6
1851
1847
}
1848
+ err = alice .PublishTransaction (tx6 , labels .External )
1849
+ require .ErrorIs (t , err , expErr )
1850
+
1851
+ // Mine the tx spending tx3.
1852
+ err = mineAndAssert (r , tx3Spend )
1853
+ require .NoError (t , err )
1852
1854
})
1853
1855
1854
1856
t .Run ("tx_double_spend" , func (t * testing.T ) {
@@ -3071,9 +3073,9 @@ func testSingleFunderExternalFundingTx(miner *rpctest.Harness,
3071
3073
)
3072
3074
}
3073
3075
3074
- // TestInterfaces tests all registered interfaces with a unified set of tests
3075
- // which exercise each of the required methods found within the WalletController
3076
- // interface.
3076
+ // TestLightningWallet tests all registered interfaces with a unified set of
3077
+ // tests which exercise each of the required methods found within the
3078
+ // WalletController interface.
3077
3079
//
3078
3080
// NOTE: In the future, when additional implementations of the WalletController
3079
3081
// interface have been implemented, in order to ensure the new concrete
0 commit comments