Never delete spent utxos from the database

A `is_spent` field is added to LocalUtxo; when a txo is spent we set
this field to true instead of deleting the entire utxo from the
database.
This allows us to create txs double-spending txs already in blockchain.
Listunspent won't return spent utxos, effectively excluding them from the
coin selection and balance calculation
This commit is contained in:
Daniela Brozzoni
2022-03-09 16:15:34 +01:00
parent 3e4678d8e3
commit f2f0efc0b3
13 changed files with 155 additions and 66 deletions

View File

@@ -569,6 +569,7 @@ mod test {
script_pubkey: Script::new(),
},
keychain: KeychainKind::External,
is_spent: false,
}),
}
}
@@ -596,6 +597,7 @@ mod test {
script_pubkey: Script::new(),
},
keychain: KeychainKind::External,
is_spent: false,
}),
});
}
@@ -615,6 +617,7 @@ mod test {
script_pubkey: Script::new(),
},
keychain: KeychainKind::External,
is_spent: false,
}),
};
vec![utxo; utxos_number]