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

You cannot add an unspendable coin #139

Open
jole95 opened this issue Jun 10, 2020 · 4 comments
Open

You cannot add an unspendable coin #139

jole95 opened this issue Jun 10, 2020 · 4 comments

Comments

@jole95
Copy link

jole95 commented Jun 10, 2020

Hi,
I have problem with second transaction. When I use first txtID everything is OK, but when I use second txtID appears "You cannot add an unspendable coin".
MY second txtID is:
8b94a5589cf0416c4e0c0b4a289d31f6db7987756e5e7653d42c3dbd60eb7b14
Nbitcoin + Qbitninja.client is awsome for me. If I found resolve, I'd be very happy :)

Thanks a lot :)

@veektorh
Copy link

veektorh commented Jun 28, 2020

from the source code https://github.com/MetacoSA/NBitcoin/blob/master/NBitcoin/TransactionBuilder.cs
line 857 - 866

when you call AddCoins() method , it checks if the coin is spendable , if its not it throws an error.

public TransactionBuilder AddCoins(IEnumerable<ICoin> coins)
		{
			foreach (var coin in coins)
			{
				if (coin.TxOut.ScriptPubKey.IsUnspendable)
					throw new InvalidOperationException("You cannot add an unspendable coin");
				CurrentGroup.Coins.AddOrReplace(coin.Outpoint, coin);
			}
			return this;
		}

@NicolasDorier
Copy link
Collaborator

NicolasDorier commented Jul 1, 2020

Yeah, if you add an unspendable coin, we indeed cna't spend it and it should crash.

What part of the book does it relate to?

@veektorh
Copy link

veektorh commented Jul 1, 2020

@NicolasDorier this is a different question, I don't want to open an issue on it.

is it possible for nbxplorer to generate hardened addresses for me from the derivation scheme it's tracking ?

from what I know, you can't generate hardened address from xpub.

I can generate the address I want myself using private keys, But since I'll be tracking using nbxplorer, I'll like to use the addresses generated from nbxplorer

nbxplorer is currently generating address for me but it's keypath(0/0), what i want us keypath(m/84'/2'/0'/0/0).

Thanks for your time

@NicolasDorier
Copy link
Collaborator

No it can't. You need to derive the xpub at m/84'/2'/0' and pass that to nbxplorer.

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

3 participants