static Coin GetCoin(IRpcClient rpcClient) { var txId = rpcClient.SendToAddressAsync(testAddress, 0.1).Result; var tx = NBitcoin.Transaction.Load(rpcClient.GetRawTransactionAsBytesAsync(txId).Result, Network.RegTest); int?foundIndex = null; for (int i = 0; i < tx.Outputs.Count; i++) { if (tx.Outputs[i].ScriptPubKey.GetDestinationAddress(Network.RegTest).ToString() == testAddress) { foundIndex = i; break; } } if (foundIndex == null) { throw new Exception("Unable to found a transaction output with required destination address"); } return(new Coin(tx, (uint)foundIndex.Value)); }