Figured out the reward scheme

This commit is contained in:
2026-04-01 11:56:09 +02:00
parent 075793c24c
commit 06e6f02b86
6 changed files with 172 additions and 56 deletions

View File

@@ -291,7 +291,8 @@ void Block_Print(const block_t* block) {
for (size_t i = 0; i < DynArr_size(block->transactions); i++) {
signed_transaction_t* tx = (signed_transaction_t*)DynArr_at(block->transactions, i);
if (tx) {
printf(" Tx #%zu: %llu -> %llu, fee %llu\n", i, tx->transaction.amount, tx->transaction.fee, tx->transaction.amount + tx->transaction.fee);
printf(" Tx #%zu: 1: %llu -> %02x%02x...%02x%02x, fee %llu\n 2: %llu -> %02x%02x...%02x%02x, fee %llu\n",
i, tx->transaction.amount1, tx->transaction.recipientAddress1[0], tx->transaction.recipientAddress1[1], tx->transaction.recipientAddress1[30], tx->transaction.recipientAddress1[31], tx->transaction.fee, tx->transaction.amount2, tx->transaction.recipientAddress2[0], tx->transaction.recipientAddress2[1], tx->transaction.recipientAddress2[30], tx->transaction.recipientAddress2[31], tx->transaction.fee);
}
}
} else {

View File

@@ -43,11 +43,11 @@ bool Transaction_Verify(const signed_transaction_t* tx) {
return false; // Sender address does not match public key
}
if (tx->transaction.amount == 0) {
if (tx->transaction.amount1 == 0) {
return false; // Zero-amount transactions are not valid
}
if (tx->transaction.fee > tx->transaction.amount) {
if (tx->transaction.fee > tx->transaction.amount1) {
return false; // Fee cannot exceed amount
}
@@ -55,10 +55,18 @@ bool Transaction_Verify(const signed_transaction_t* tx) {
return false; // Unsupported version
}
if (Address_IsCoinbase(tx->transaction.recipientAddress)) {
if (Address_IsCoinbase(tx->transaction.recipientAddress1) || Address_IsCoinbase(tx->transaction.recipientAddress2)) {
return false; // Cannot send to coinbase address
}
if (tx->transaction.amount2 == 0) {
// If amount2 is zero, address2 must be all zeros
uint8_t zeroAddress[32] = {0};
if (memcmp(tx->transaction.recipientAddress2, zeroAddress, 32) != 0) {
return false; // amount2 is zero but address2 is not zeroed
}
}
uint8_t txHash[32];
Transaction_CalculateHash(tx, txHash);