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

Undesired behavior of Redistribute and RedistributeV2 #169

Closed
mike76-dev opened this issue Feb 9, 2025 · 2 comments · Fixed by #170
Closed

Undesired behavior of Redistribute and RedistributeV2 #169

mike76-dev opened this issue Feb 9, 2025 · 2 comments · Fixed by #170

Comments

@mike76-dev
Copy link
Contributor

I'm talking about an edge case where the SingleAddressWallet is ordered to redistribute the outputs of a wallet consisting of one single output (e.g. if that wallet was just created and funded with a single transaction).

If the desired number of outputs is greater than the batch size (e.g. 100 vs. 10), and there is only one output in the wallet, both Redistribute and RedistributeV2 create a set of identical transactions, each spending the same parent output.

Then, if the resulting transaction set is submitted to the TxPool, the whole set is rejected, because each transaction, except the very first one, double-spends the parent output, which has already been spent in the first transaction.

@mike76-dev
Copy link
Contributor Author

mike76-dev commented Feb 9, 2025

I was able to work around with this code:

numOutputs := wantedOutputs
maxOutputs := len(utxos) * redistributeBatchSize // *10
if numOutputs > maxOutputs {
	numOutputs = maxOutputs
}

So, if you don't think that this edge case needs handling, please feel free to close the issue.

@mike76-dev
Copy link
Contributor Author

Wait, something still isn't right.

Even with "enough" outputs (like, 11 out of 100 required), RedistributeV2 uses the same output in multiple transactions from the set, so the set is still bound to be rejected.

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

Successfully merging a pull request may close this issue.

1 participant