Remove Output::amount and move Payment from Amount to Balance

This code is still largely designed around the idea a payment for a network is
fungible with any other, which isn't true. This starts moving past that.

Asserts are added to ensure the integrity of coin to the scheduler (which is
now per key per coin, not per key alone) and in Bitcoin/Monero prepare_send.
This commit is contained in:
Luke Parker
2023-11-08 23:33:25 -05:00
parent ffedba7a05
commit 7d72e224f0
10 changed files with 201 additions and 87 deletions

View File

@@ -553,7 +553,7 @@ impl<N: Network, D: Db> Scanner<N, D> {
// TODO: These lines are the ones which will cause a really long-lived lock acquisiton
for output in network.get_outputs(&block, key).await {
assert_eq!(output.key(), key);
if output.amount() >= N::DUST {
if output.balance().amount.0 >= N::DUST {
outputs.push(output);
}
}
@@ -580,10 +580,10 @@ impl<N: Network, D: Db> Scanner<N, D> {
for output in &outputs {
let id = output.id();
info!(
"block {} had output {} worth {}",
"block {} had output {} worth {:?}",
hex::encode(&block_id),
hex::encode(&id),
output.amount(),
output.balance(),
);
// On Bitcoin, the output ID should be unique for a given chain