So, I am trying to send some money over using NBitcoin, there is a step where I am failing and that is creating de bitcoin secret to sign the transaction, I have the address, and the ExtPrivKey but I haven't gotten any luck signing it, any recommendation, this is my code below.
var priv = mbwallet.SelectedWallet.PrivateKeys[0].ToWif(); //var ool = new BitcoinSecret(base58, App.Network); var privkey = mbwallet.SelectedWallet.PrivateKeys[0].PrivateKey.GetBitcoinSecret(App.Network).ToWif(); var key = Key.Parse(privkey, App.Network); var keysT = key.GetWif(App.Network); //var myaddress = mbwallet.SelectedWallet.PrivateKeys[0].PrivateKey.PubKey.GetAddress(App.Network); var myaddress = mbwallet.SelectedWallet.CurrentAddress; string address = Address.Text; var destination = BitcoinAddress.Create(address, App.Network); decimal value = Convert.ToDecimal(Value.Text); var coins2 = GetCoins(value); TransactionBuilder txBuilder = new TransactionBuilder(); var tx = txBuilder.AddCoins(coins2) .AddKeys(keysT) .SetChange(myaddress) .Send(destination, new Money(value, MoneyUnit.BTC)) .SendFees("0.0002"); //.BuildTransaction(true); var tx2 = txBuilder.BuildTransaction(true); //Console.WriteLine(txBuilder.Verify(tx)); var hello = tx2.ToHex(); var txRepo = new NoSqlTransactionRepository(); //txRepo.Put(tx.GetHash(), tx); //Assert(txBuilder.Verify(tx)); //check fully signed List<ICoin> GetCoins(decimal sendAmount) { //var mbwallet = (root.DataContext as MainWindowViewModel); var amountMoney = new Money(sendAmount, MoneyUnit.BTC); var client = new QBitNinjaClient(App.Network); var txInAmount = Money.Zero; var coins1 = new List<ICoin>(); foreach (var balance in client.GetBalance(mbwallet.SelectedWallet.CurrentAddress,//MBWallet.Wallet.Address, true).Result.Operations) { var transactionId = balance.TransactionId; var transactionResponse = client.GetTransaction(transactionId).Result; var receivedCoins = transactionResponse.ReceivedCoins; foreach (Coin coin in receivedCoins) { if (coin.TxOut.ScriptPubKey == mbwallet.SelectedWallet.CurrentAddress.ScriptPubKey)//MBWallet.Wallet.BitcoinPrivateKey.ScriptPubKey) // this may not be necessary { coins1.Add(coin); txInAmount += (coin.Amount as Money); } } } return coins1; }