Hello. I can't make a transaction in testnet between two wallet. Any idea? Thanks. Here is my code :
// wallet 1
BitcoinSecret alice = new BitcoinSecret("cVRq7YR616m5Ae98khjDRrzU29i93HPMgiftDB5m5avti4z21A5x", Network.TestNet);
//wallet2
BitcoinSecret satoshi = new BitcoinSecret("93GTrdzRTMzEUa5E3ZAhdQgQweM6dJhnZqGztHRzH8TMmPE9vXF", Network.TestNet);
//transaction
Console.WriteLine(alice.GetAddress());
Console.WriteLine(satoshi.GetAddress());
var txRepo = new NoSqlTransactionRepository();
Transaction aliceFunding = new Transaction()
{
Outputs =
{
new TxOut("0.0009", alice.GetAddress()),
new TxOut("0.0003", alice.PubKey)
}
};
Coin[] aliceCoins = aliceFunding
.Outputs
.Select((o, i) => new Coin(new OutPoint(aliceFunding.GetHash(), i), o))
.ToArray();
var txBuilder = new TransactionBuilder();
var tx = txBuilder
.AddCoins(aliceCoins)
.AddKeys(alice.PrivateKey)
.Send(satoshi.GetAddress(), "0.0009")
.SendFees("0.0003")
.SetChange(alice.GetAddress())
.BuildTransaction(true);
txRepo.Put(tx.GetHash(), tx);
Console.WriteLine(txBuilder.Verify(tx));
Console.WriteLine(tx.GetHash().ToString());
var client = new QBitNinjaClient(Network.TestNet);
BroadcastResponse broadcastResponse = client.Broadcast(tx).Result;
if (!broadcastResponse.Success)
{
Console.WriteLine("ErrorCode: {0}", broadcastResponse.Error.ErrorCode);
}
else
{
Console.WriteLine("Success! You can check out the hash of the transaciton in any block explorer:");
}
var node = Node.Connect(Network.TestNet);
node.VersionHandshake();
node.SendMessage(new InvPayload(InventoryType.MSG_TX, tx.GetHash()));
node.SendMessage(new TxPayload(tx));
Console.ReadKey();