NBXplorer: How to create a transaction? Can't get it verified
I’ve got some unspentCoins to different addresses some to Root ExtPubKey and some to derived ExtPubKeys. Now I want to spend it and can’t verify the transaction. My code looks like this:
var privateKeys = new List<ExtKey>();
var rootPrivateKey = GetRootPubKey(...);
var extRootPubKey = privateKey.Neuter();
privateKeys.Add(extRootPubKey);
var unused = await nbxplorer.GetUnusedAsync(userDerivationScheme, DerivationFeature.Deposit);
var maxUnusedNumber = unused.KeyPath.Indexes.Max();
for (UInt32 i = 0; i <= maxUnusedNumber ; i++)
{
extPrivateKeys.Add(privateKey.Derive(i));
}
var changeAddress = await = nbxplorer.GetUnusedAsync(userDerivationScheme, DerivationFeature.Change);
var builder = new TransactionBuilder();
builder = builder
.AddCoins(unspentCoins)
.AddKeys(extPrivateKeys.ToArray())
.Send(destinationPubKey, amountMoney);
.SetChange(changeAddress)
.SendFees(new Money(fee, MoneyUnit.BTC))
.BuildTransaction(true);
verified = builder.Verify(tx);
// unfortunately verified is false
What did I do wrong?
Thank you in advance.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 15 (7 by maintainers)
Yes it’s correct. But I created a wallet with sending & receiving to root key only and now I want to migrate it to BIP44 without loosing existing assets.
Thank you again.