Commit 323470d 1 parent c28d618 commit 323470d Copy full SHA for 323470d
File tree 2 files changed +15
-1
lines changed
2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -266,7 +266,7 @@ impl DaemonControl {
266
266
. increment ( )
267
267
. expect ( "Must not get into hardened territory" ) ;
268
268
db_conn. set_change_index ( next_index, & self . secp ) ;
269
- } else if !is_change && db_conn. receive_index ( ) < * index {
269
+ } else if !is_change && db_conn. receive_index ( ) <= * index {
270
270
let next_index = index
271
271
. increment ( )
272
272
. expect ( "Must not get into hardened territory" ) ;
Original file line number Diff line number Diff line change @@ -245,6 +245,20 @@ def test_send_to_self(lianad, bitcoind):
245
245
)
246
246
wait_for (lambda : len (list (unspent_coins ())) == 1 )
247
247
248
+ # We've used 3 receive addresses and so the DB receive index must be 3.
249
+ assert len (lianad .rpc .listaddresses ()["addresses" ]) == 3
250
+ # Create a new spend to the receive address with index 3.
251
+ recv_addr = lianad .rpc .listaddresses (3 , 1 )["addresses" ][0 ]["receive" ]
252
+ res = lianad .rpc .createspend ({recv_addr : 11_955_000 }, [], 1 )
253
+ assert "psbt" in res
254
+ # Max(receive_index, change_index) is now 4:
255
+ assert len (lianad .rpc .listaddresses ()["addresses" ]) == 4
256
+ # But the spend has no change:
257
+ psbt = PSBT .from_base64 (res ["psbt" ])
258
+ assert len (psbt .o ) == 1
259
+ # As the spend has no change, only the receive index was incremented.
260
+ # Therefore, the DB receive index is now 4.
261
+
248
262
249
263
def test_coin_selection (lianad , bitcoind ):
250
264
"""We can create a spend using coin selection."""
You can’t perform that action at this time.
0 commit comments