Merge #317: bitcoind: detect deposits from (mature) coinbase transactions
af058d59e3604cebb7384f4c0f65a2fd60cc5af4 bitcoind: detect deposits from (mature) coinbase transactions (Antoine Poinsot) Pull request description: What if miners use Liana! 😁 ACKs for top commit: edouardparis: ⛏️ utACK af058d59e3604cebb7384f4c0f65a2fd60cc5af4 Tree-SHA512: 579e24b78d250c095e1073e6e1df46bbea77afdcde6ee8dcef7adc29ef276b6609ccc829809dd97c2da8679ffb6d7b60041572a017438cc7695acdc6afad5b71
This commit is contained in:
commit
e8d0f492b9
@ -1073,11 +1073,17 @@ impl From<Json> for LSBlockRes {
|
||||
.expect("Array must be present")
|
||||
.iter()
|
||||
.filter_map(|j| {
|
||||
if j.get("category")
|
||||
// From 'listunspent' help:
|
||||
// "send" Transactions sent.
|
||||
// "receive" Non-coinbase transactions received.
|
||||
// "generate" Coinbase transactions received with more than 100 confirmations.
|
||||
// "immature" Coinbase transactions received with 100 or fewer confirmations.
|
||||
// "orphan" Orphaned coinbase transactions received.
|
||||
let category = j
|
||||
.get("category")
|
||||
.and_then(Json::as_str)
|
||||
.expect("must be present")
|
||||
== "receive"
|
||||
{
|
||||
.expect("must be present");
|
||||
if category == "receive" || category == "generate" {
|
||||
let lsb_entry: LSBlockEntry = j.into();
|
||||
Some(lsb_entry)
|
||||
} else {
|
||||
|
||||
@ -72,3 +72,17 @@ def test_multisig(lianad_multisig, bitcoind):
|
||||
signed_psbt = lianad.signer.sign_psbt(reco_psbt, [1, 4], recovery=True)
|
||||
lianad.rpc.updatespend(signed_psbt.to_base64())
|
||||
lianad.rpc.broadcastspend(txid)
|
||||
|
||||
|
||||
def test_coinbase_deposit(lianad, bitcoind):
|
||||
"""Check we detect deposits from (mature) coinbase transactions."""
|
||||
# Create a new deposit in a coinbase transaction.
|
||||
addr = lianad.rpc.getnewaddress()["address"]
|
||||
bitcoind.rpc.generatetoaddress(1, addr)
|
||||
assert len(lianad.rpc.listcoins()["coins"]) == 0
|
||||
|
||||
# Generate 100 blocks to make the coinbase mature.
|
||||
bitcoind.generate_block(100)
|
||||
|
||||
# We must have detected a new deposit.
|
||||
wait_for(lambda: len(lianad.rpc.listcoins()["coins"]) == 1)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user