commands: increment receive index on each use
This is a similar fix as for the change index.
This commit is contained in:
parent
cc5e396ace
commit
bfd6ca517b
@ -267,7 +267,7 @@ impl DaemonControl {
|
||||
.increment()
|
||||
.expect("Must not get into hardened territory");
|
||||
db_conn.set_change_index(next_index, &self.secp);
|
||||
} else if !is_change && db_conn.receive_index() < *index {
|
||||
} else if !is_change && db_conn.receive_index() <= *index {
|
||||
let next_index = index
|
||||
.increment()
|
||||
.expect("Must not get into hardened territory");
|
||||
|
||||
@ -246,6 +246,20 @@ def test_send_to_self(lianad, bitcoind):
|
||||
)
|
||||
wait_for(lambda: len(list(unspent_coins())) == 1)
|
||||
|
||||
# We've used 3 receive addresses and so the DB receive index must be 3.
|
||||
assert len(lianad.rpc.listaddresses()["addresses"]) == 3
|
||||
# Create a new spend to the receive address with index 3.
|
||||
recv_addr = lianad.rpc.listaddresses(3, 1)["addresses"][0]["receive"]
|
||||
res = lianad.rpc.createspend({recv_addr: 11_955_000}, [], 1)
|
||||
assert "psbt" in res
|
||||
# Max(receive_index, change_index) is now 4:
|
||||
assert len(lianad.rpc.listaddresses()["addresses"]) == 4
|
||||
# But the spend has no change:
|
||||
psbt = PSBT.from_base64(res["psbt"])
|
||||
assert len(psbt.o) == 1
|
||||
# As the spend has no change, only the receive index was incremented.
|
||||
# Therefore, the DB receive index is now 4.
|
||||
|
||||
|
||||
def test_coin_selection(lianad, bitcoind):
|
||||
"""We can create a spend using coin selection."""
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user