Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Part_4: Explanation of FindUnspentTransactions method #3

Open
shaunmj opened this issue Jul 12, 2019 · 2 comments
Open

Part_4: Explanation of FindUnspentTransactions method #3

shaunmj opened this issue Jul 12, 2019 · 2 comments

Comments

@shaunmj
Copy link

shaunmj commented Jul 12, 2019

Hi Tensor, I have a question pertaining to the FindUnspentTransactions method.

What I want to know is why the check for whether the Transaction is a Coinbase is done after the for loop through the transactions outputs. Should it be done before the for loop so that there will be spentTXOs to iterate through?

@Jwdev-wr
Copy link

Jwdev-wr commented Aug 4, 2019

I believe it needs to append the unspent transactions first, before it can add the spentTx's.

So on the first run of that function the spent transactions will be nil, so than coinbase account gets the unspent transactions. Then the next time its run it will be able to add the spent transactions if they occurred.

@shaunmj
Copy link
Author

shaunmj commented Aug 8, 2019

ok understood. @WhiteRaBot17
Another bunch of questions,

  1. From the definition of an unspent transaction is a "transaction that have outputs that are not referenced by other inputs". Does this refer to AT LEAST one output that isn't referenced by other inputs, or ALL outputs aren't referenced by other inputs?

  2. The code snippet below

	if out.CanBeUnlocked(address) {
		unspentTxs = append(unspentTxs, *tx)
	}

How does checking for whether an output can be unlocked indicate whether an output is referenced by inputs and confirm whether the transaction is unspent?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants